markup.c \
menus.c \
modelbutton.c \
- offscreen_window.c \
- offscreen_window2.c \
overlay.c \
overlay2.c \
panes.c \
<file>markup.c</file>
<file>menus.c</file>
<file>modelbutton.c</file>
- <file>offscreen_window.c</file>
- <file>offscreen_window2.c</file>
<file>overlay.c</file>
<file>overlay2.c</file>
<file>pagesetup.c</file>
+++ /dev/null
-/* Offscreen Windows/Rotated Button
- *
- * Offscreen windows can be used to transform parts of a widget
- * hierarchy. Note that the rotated button is fully functional.
- */
-#include <math.h>
-#include <gtk/gtk.h>
-
-#define GTK_TYPE_ROTATED_BIN (gtk_rotated_bin_get_type ())
-#define GTK_ROTATED_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ROTATED_BIN, GtkRotatedBin))
-#define GTK_ROTATED_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ROTATED_BIN, GtkRotatedBinClass))
-#define GTK_IS_ROTATED_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ROTATED_BIN))
-#define GTK_IS_ROTATED_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ROTATED_BIN))
-#define GTK_ROTATED_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ROTATED_BIN, GtkRotatedBinClass))
-
-typedef struct _GtkRotatedBin GtkRotatedBin;
-typedef struct _GtkRotatedBinClass GtkRotatedBinClass;
-
-struct _GtkRotatedBin
-{
- GtkContainer container;
-
- GtkWidget *child;
- GdkWindow *offscreen_window;
- gdouble angle;
-};
-
-struct _GtkRotatedBinClass
-{
- GtkContainerClass parent_class;
-};
-
-GType gtk_rotated_bin_get_type (void) G_GNUC_CONST;
-GtkWidget* gtk_rotated_bin_new (void);
-void gtk_rotated_bin_set_angle (GtkRotatedBin *bin,
- gdouble angle);
-
-/*** implementation ***/
-
-static void gtk_rotated_bin_realize (GtkWidget *widget);
-static void gtk_rotated_bin_unrealize (GtkWidget *widget);
-static void gtk_rotated_bin_measure (GtkWidget *widget,
- GtkOrientation orientation,
- int for_size,
- int *minimum,
- int *natural,
- int *minimum_baseline,
- int *natural_baseline);
-static void gtk_rotated_bin_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gboolean gtk_rotated_bin_damage (GtkWidget *widget,
- GdkEventExpose *event);
-static gboolean gtk_rotated_bin_draw (GtkWidget *widget,
- cairo_t *cr);
-
-static void gtk_rotated_bin_add (GtkContainer *container,
- GtkWidget *child);
-static void gtk_rotated_bin_remove (GtkContainer *container,
- GtkWidget *widget);
-static void gtk_rotated_bin_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static GType gtk_rotated_bin_child_type (GtkContainer *container);
-
-G_DEFINE_TYPE (GtkRotatedBin, gtk_rotated_bin, GTK_TYPE_CONTAINER);
-
-static void
-to_child (GtkRotatedBin *bin,
- double widget_x,
- double widget_y,
- double *x_out,
- double *y_out)
-{
- GtkAllocation child_area;
- double x, y, xr, yr;
- double c, s;
- double w, h;
-
- s = sin (bin->angle);
- c = cos (bin->angle);
- gtk_widget_get_allocation (bin->child, &child_area);
-
- w = c * child_area.width + s * child_area.height;
- h = s * child_area.width + c * child_area.height;
-
- x = widget_x;
- y = widget_y;
-
- x -= (w - child_area.width) / 2;
- y -= (h - child_area.height) / 2;
-
- x -= child_area.width / 2;
- y -= child_area.height / 2;
-
- xr = x * c + y * s;
- yr = y * c - x * s;
- x = xr;
- y = yr;
-
- x += child_area.width / 2;
- y += child_area.height / 2;
-
- *x_out = x;
- *y_out = y;
-}
-
-static void
-to_parent (GtkRotatedBin *bin,
- double offscreen_x,
- double offscreen_y,
- double *x_out,
- double *y_out)
-{
- GtkAllocation child_area;
- double x, y, xr, yr;
- double c, s;
- double w, h;
-
- s = sin (bin->angle);
- c = cos (bin->angle);
- gtk_widget_get_allocation (bin->child, &child_area);
-
- w = c * child_area.width + s * child_area.height;
- h = s * child_area.width + c * child_area.height;
-
- x = offscreen_x;
- y = offscreen_y;
-
- x -= child_area.width / 2;
- y -= child_area.height / 2;
-
- xr = x * c - y * s;
- yr = x * s + y * c;
- x = xr;
- y = yr;
-
- x += child_area.width / 2;
- y += child_area.height / 2;
-
- x -= (w - child_area.width) / 2;
- y -= (h - child_area.height) / 2;
-
- *x_out = x;
- *y_out = y;
-}
-
-static void
-gtk_rotated_bin_class_init (GtkRotatedBinClass *klass)
-{
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
-
- widget_class->realize = gtk_rotated_bin_realize;
- widget_class->unrealize = gtk_rotated_bin_unrealize;
- widget_class->measure = gtk_rotated_bin_measure;
- widget_class->size_allocate = gtk_rotated_bin_size_allocate;
- widget_class->draw = gtk_rotated_bin_draw;
-
- g_signal_override_class_closure (g_signal_lookup ("damage-event", GTK_TYPE_WIDGET),
- GTK_TYPE_ROTATED_BIN,
- g_cclosure_new (G_CALLBACK (gtk_rotated_bin_damage),
- NULL, NULL));
-
- container_class->add = gtk_rotated_bin_add;
- container_class->remove = gtk_rotated_bin_remove;
- container_class->forall = gtk_rotated_bin_forall;
- container_class->child_type = gtk_rotated_bin_child_type;
-}
-
-static void
-gtk_rotated_bin_init (GtkRotatedBin *bin)
-{
- gtk_widget_set_has_window (GTK_WIDGET (bin), TRUE);
-}
-
-GtkWidget *
-gtk_rotated_bin_new (void)
-{
- return g_object_new (GTK_TYPE_ROTATED_BIN, NULL);
-}
-
-static GdkWindow *
-pick_offscreen_child (GdkWindow *offscreen_window,
- double widget_x,
- double widget_y,
- GtkRotatedBin *bin)
-{
- GtkAllocation child_area;
- double x, y;
-
- if (bin->child && gtk_widget_get_visible (bin->child))
- {
- to_child (bin, widget_x, widget_y, &x, &y);
-
- gtk_widget_get_allocation (bin->child, &child_area);
-
- if (x >= 0 && x < child_area.width &&
- y >= 0 && y < child_area.height)
- return bin->offscreen_window;
- }
-
- return NULL;
-}
-
-static void
-offscreen_window_to_parent (GdkWindow *offscreen_window,
- double offscreen_x,
- double offscreen_y,
- double *parent_x,
- double *parent_y,
- GtkRotatedBin *bin)
-{
- to_parent (bin, offscreen_x, offscreen_y, parent_x, parent_y);
-}
-
-static void
-offscreen_window_from_parent (GdkWindow *window,
- double parent_x,
- double parent_y,
- double *offscreen_x,
- double *offscreen_y,
- GtkRotatedBin *bin)
-{
- to_child (bin, parent_x, parent_y, offscreen_x, offscreen_y);
-}
-
-static void
-gtk_rotated_bin_realize (GtkWidget *widget)
-{
- GtkRotatedBin *bin = GTK_ROTATED_BIN (widget);
- GtkAllocation allocation;
- GdkWindow *window;
- GdkWindowAttr attributes;
- gint attributes_mask;
- GtkRequisition child_requisition;
-
- gtk_widget_set_realized (widget, TRUE);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- attributes.x = allocation.x;
- attributes.y = allocation.y;
- attributes.width = allocation.width;
- attributes.height = allocation.height;
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.event_mask = gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_POINTER_MOTION_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_SCROLL_MASK
- | GDK_ENTER_NOTIFY_MASK
- | GDK_LEAVE_NOTIFY_MASK;
-
- attributes.wclass = GDK_INPUT_OUTPUT;
-
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gtk_widget_set_window (widget, window);
- gdk_window_set_user_data (window, widget);
- g_signal_connect (window, "pick-embedded-child",
- G_CALLBACK (pick_offscreen_child), bin);
-
- attributes.window_type = GDK_WINDOW_OFFSCREEN;
-
- child_requisition.width = child_requisition.height = 0;
- if (bin->child && gtk_widget_get_visible (bin->child))
- {
- GtkAllocation child_allocation;
-
- gtk_widget_get_allocation (bin->child, &child_allocation);
- attributes.width = child_allocation.width;
- attributes.height = child_allocation.height;
- }
- bin->offscreen_window = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)),
- &attributes, attributes_mask);
- gdk_window_set_user_data (bin->offscreen_window, widget);
- if (bin->child)
- gtk_widget_set_parent_window (bin->child, bin->offscreen_window);
- gdk_offscreen_window_set_embedder (bin->offscreen_window, window);
- g_signal_connect (bin->offscreen_window, "to-embedder",
- G_CALLBACK (offscreen_window_to_parent), bin);
- g_signal_connect (bin->offscreen_window, "from-embedder",
- G_CALLBACK (offscreen_window_from_parent), bin);
-
- gdk_window_show (bin->offscreen_window);
-}
-
-static void
-gtk_rotated_bin_unrealize (GtkWidget *widget)
-{
- GtkRotatedBin *bin = GTK_ROTATED_BIN (widget);
-
- gdk_window_set_user_data (bin->offscreen_window, NULL);
- gdk_window_destroy (bin->offscreen_window);
- bin->offscreen_window = NULL;
-
- GTK_WIDGET_CLASS (gtk_rotated_bin_parent_class)->unrealize (widget);
-}
-
-static GType
-gtk_rotated_bin_child_type (GtkContainer *container)
-{
- GtkRotatedBin *bin = GTK_ROTATED_BIN (container);
-
- if (bin->child)
- return G_TYPE_NONE;
-
- return GTK_TYPE_WIDGET;
-}
-
-static void
-gtk_rotated_bin_add (GtkContainer *container,
- GtkWidget *widget)
-{
- GtkRotatedBin *bin = GTK_ROTATED_BIN (container);
-
- if (!bin->child)
- {
- gtk_widget_set_parent_window (widget, bin->offscreen_window);
- gtk_widget_set_parent (widget, GTK_WIDGET (bin));
- bin->child = widget;
- }
- else
- g_warning ("GtkRotatedBin cannot have more than one child");
-}
-
-static void
-gtk_rotated_bin_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- GtkRotatedBin *bin = GTK_ROTATED_BIN (container);
- gboolean was_visible;
-
- was_visible = gtk_widget_get_visible (widget);
-
- if (bin->child == widget)
- {
- gtk_widget_unparent (widget);
-
- bin->child = NULL;
-
- if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container)))
- gtk_widget_queue_resize (GTK_WIDGET (container));
- }
-}
-
-static void
-gtk_rotated_bin_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GtkRotatedBin *bin = GTK_ROTATED_BIN (container);
-
- g_return_if_fail (callback != NULL);
-
- if (bin->child)
- (*callback) (bin->child, callback_data);
-}
-
-void
-gtk_rotated_bin_set_angle (GtkRotatedBin *bin,
- gdouble angle)
-{
- g_return_if_fail (GTK_IS_ROTATED_BIN (bin));
-
- bin->angle = angle;
- gtk_widget_queue_resize (GTK_WIDGET (bin));
-
- gdk_window_geometry_changed (bin->offscreen_window);
-}
-
-static void
-gtk_rotated_bin_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GtkRotatedBin *bin = GTK_ROTATED_BIN (widget);
- GtkRequisition child_requisition;
- double s, c;
-
- child_requisition.width = 0;
- child_requisition.height = 0;
-
- if (bin->child && gtk_widget_get_visible (bin->child))
- gtk_widget_get_preferred_size ( (bin->child),
- &child_requisition, NULL);
-
- s = sin (bin->angle);
- c = cos (bin->angle);
- requisition->width = c * child_requisition.width + s * child_requisition.height;
- requisition->height = s * child_requisition.width + c * child_requisition.height;
-}
-
-static void
-gtk_rotated_bin_measure (GtkWidget *widget,
- GtkOrientation orientation,
- int for_size,
- int *minimum,
- int *natural,
- int *minimum_baseline,
- int *natural_baseline)
-{
- GtkRequisition requisition;
-
- gtk_rotated_bin_size_request (widget, &requisition);
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- *minimum = *natural = requisition.width;
- else
- *minimum = *natural = requisition.height;
-}
-
-static void
-gtk_rotated_bin_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GtkRotatedBin *bin = GTK_ROTATED_BIN (widget);
- gint w, h;
- gdouble s, c;
-
- gtk_widget_set_allocation (widget, allocation);
-
- w = allocation->width;
- h = allocation->height;
-
- if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (gtk_widget_get_window (widget),
- allocation->x,
- allocation->y,
- w, h);
-
- if (bin->child && gtk_widget_get_visible (bin->child))
- {
- GtkRequisition child_requisition;
- GtkAllocation child_allocation;
-
- s = sin (bin->angle);
- c = cos (bin->angle);
-
- gtk_widget_get_preferred_size (bin->child,
- &child_requisition, NULL);
- child_allocation.x = 0;
- child_allocation.y = 0;
- child_allocation.height = child_requisition.height;
- if (c == 0.0)
- child_allocation.width = h / s;
- else if (s == 0.0)
- child_allocation.width = w / c;
- else
- child_allocation.width = MIN ((w - s * child_allocation.height) / c,
- (h - c * child_allocation.height) / s);
-
- if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (bin->offscreen_window,
- child_allocation.x,
- child_allocation.y,
- child_allocation.width,
- child_allocation.height);
-
- child_allocation.x = child_allocation.y = 0;
- gtk_widget_size_allocate (bin->child, &child_allocation);
- }
-}
-
-static gboolean
-gtk_rotated_bin_damage (GtkWidget *widget,
- GdkEventExpose *event)
-{
- gdk_window_invalidate_rect (gtk_widget_get_window (widget),
- NULL, FALSE);
-
- return TRUE;
-}
-
-static gboolean
-gtk_rotated_bin_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- GtkRotatedBin *bin = GTK_ROTATED_BIN (widget);
- GdkWindow *window;
- gdouble s, c;
- gdouble w, h;
-
- window = gtk_widget_get_window (widget);
- if (gtk_cairo_should_draw_window (cr, window))
- {
- cairo_surface_t *surface;
- GtkAllocation child_area;
-
- if (bin->child && gtk_widget_get_visible (bin->child))
- {
- surface = gdk_offscreen_window_get_surface (bin->offscreen_window);
- gtk_widget_get_allocation (bin->child, &child_area);
-
- /* transform */
- s = sin (bin->angle);
- c = cos (bin->angle);
- w = c * child_area.width + s * child_area.height;
- h = s * child_area.width + c * child_area.height;
-
- cairo_translate (cr, (w - child_area.width) / 2, (h - child_area.height) / 2);
- cairo_translate (cr, child_area.width / 2, child_area.height / 2);
- cairo_rotate (cr, bin->angle);
- cairo_translate (cr, -child_area.width / 2, -child_area.height / 2);
-
- /* clip */
- cairo_rectangle (cr,
- 0, 0,
- gdk_window_get_width (bin->offscreen_window),
- gdk_window_get_height (bin->offscreen_window));
- cairo_clip (cr);
- /* paint */
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_paint (cr);
- }
- }
- if (gtk_cairo_should_draw_window (cr, bin->offscreen_window))
- {
- gtk_render_background (gtk_widget_get_style_context (widget),
- cr,
- 0, 0,
- gdk_window_get_width (bin->offscreen_window),
- gdk_window_get_height (bin->offscreen_window));
-
- if (bin->child)
- gtk_container_propagate_draw (GTK_CONTAINER (widget),
- bin->child,
- cr);
- }
-
- return FALSE;
-}
-
-/*** ***/
-
-static void
-scale_changed (GtkRange *range,
- GtkRotatedBin *bin)
-{
- gtk_rotated_bin_set_angle (bin, gtk_range_get_value (range));
-}
-
-GtkWidget *
-do_offscreen_window (GtkWidget *do_widget)
-{
- static GtkWidget *window = NULL;
-
- if (!window)
- {
- GtkWidget *bin, *vbox, *scale, *button;
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_screen (GTK_WINDOW (window),
- gtk_widget_get_screen (do_widget));
- gtk_window_set_title (GTK_WINDOW (window), "Rotated Button");
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
- 0, G_PI/2, 0.01);
- gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
-
- button = gtk_button_new_with_label ("A Button");
- bin = gtk_rotated_bin_new ();
-
- g_signal_connect (scale, "value-changed", G_CALLBACK (scale_changed), bin);
-
- gtk_container_add (GTK_CONTAINER (window), vbox);
- gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE);
- gtk_box_pack_start (GTK_BOX (vbox), bin, TRUE, TRUE);
- gtk_container_add (GTK_CONTAINER (bin), button);
- }
-
- if (!gtk_widget_get_visible (window))
- gtk_widget_show_all (window);
- else
- gtk_widget_destroy (window);
-
- return window;
-}
+++ /dev/null
-/* Offscreen Windows/Effects
- *
- * Offscreen windows can be used to render elements multiple times to achieve
- * various effects.
- */
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-
-#define GTK_TYPE_MIRROR_BIN (gtk_mirror_bin_get_type ())
-#define GTK_MIRROR_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MIRROR_BIN, GtkMirrorBin))
-#define GTK_MIRROR_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MIRROR_BIN, GtkMirrorBinClass))
-#define GTK_IS_MIRROR_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MIRROR_BIN))
-#define GTK_IS_MIRROR_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MIRROR_BIN))
-#define GTK_MIRROR_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MIRROR_BIN, GtkMirrorBinClass))
-
-typedef struct _GtkMirrorBin GtkMirrorBin;
-typedef struct _GtkMirrorBinClass GtkMirrorBinClass;
-
-struct _GtkMirrorBin
-{
- GtkContainer container;
-
- GtkWidget *child;
- GdkWindow *offscreen_window;
-};
-
-struct _GtkMirrorBinClass
-{
- GtkContainerClass parent_class;
-};
-
-GType gtk_mirror_bin_get_type (void) G_GNUC_CONST;
-GtkWidget* gtk_mirror_bin_new (void);
-
-/*** implementation ***/
-
-static void gtk_mirror_bin_realize (GtkWidget *widget);
-static void gtk_mirror_bin_unrealize (GtkWidget *widget);
-static void gtk_mirror_bin_measure (GtkWidget *widget,
- GtkOrientation orientation,
- int for_size,
- int *minimum,
- int *natural,
- int *minimum_baseline,
- int *natural_baseline);
-static void gtk_mirror_bin_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gboolean gtk_mirror_bin_damage (GtkWidget *widget,
- GdkEventExpose *event);
-static gboolean gtk_mirror_bin_draw (GtkWidget *widget,
- cairo_t *cr);
-
-static void gtk_mirror_bin_add (GtkContainer *container,
- GtkWidget *child);
-static void gtk_mirror_bin_remove (GtkContainer *container,
- GtkWidget *widget);
-static void gtk_mirror_bin_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static GType gtk_mirror_bin_child_type (GtkContainer *container);
-
-G_DEFINE_TYPE (GtkMirrorBin, gtk_mirror_bin, GTK_TYPE_CONTAINER);
-
-static void
-to_child (GtkMirrorBin *bin,
- double widget_x,
- double widget_y,
- double *x_out,
- double *y_out)
-{
- *x_out = widget_x;
- *y_out = widget_y;
-}
-
-static void
-to_parent (GtkMirrorBin *bin,
- double offscreen_x,
- double offscreen_y,
- double *x_out,
- double *y_out)
-{
- *x_out = offscreen_x;
- *y_out = offscreen_y;
-}
-
-static void
-gtk_mirror_bin_class_init (GtkMirrorBinClass *klass)
-{
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
-
- widget_class->realize = gtk_mirror_bin_realize;
- widget_class->unrealize = gtk_mirror_bin_unrealize;
- widget_class->measure = gtk_mirror_bin_measure;
- widget_class->size_allocate = gtk_mirror_bin_size_allocate;
- widget_class->draw = gtk_mirror_bin_draw;
-
- g_signal_override_class_closure (g_signal_lookup ("damage-event", GTK_TYPE_WIDGET),
- GTK_TYPE_MIRROR_BIN,
- g_cclosure_new (G_CALLBACK (gtk_mirror_bin_damage),
- NULL, NULL));
-
- container_class->add = gtk_mirror_bin_add;
- container_class->remove = gtk_mirror_bin_remove;
- container_class->forall = gtk_mirror_bin_forall;
- container_class->child_type = gtk_mirror_bin_child_type;
-}
-
-static void
-gtk_mirror_bin_init (GtkMirrorBin *bin)
-{
- gtk_widget_set_has_window (GTK_WIDGET (bin), TRUE);
-}
-
-GtkWidget *
-gtk_mirror_bin_new (void)
-{
- return g_object_new (GTK_TYPE_MIRROR_BIN, NULL);
-}
-
-static GdkWindow *
-pick_offscreen_child (GdkWindow *offscreen_window,
- double widget_x,
- double widget_y,
- GtkMirrorBin *bin)
-{
- GtkAllocation child_area;
- double x, y;
-
- if (bin->child && gtk_widget_get_visible (bin->child))
- {
- to_child (bin, widget_x, widget_y, &x, &y);
-
- gtk_widget_get_allocation (bin->child, &child_area);
-
- if (x >= 0 && x < child_area.width &&
- y >= 0 && y < child_area.height)
- return bin->offscreen_window;
- }
-
- return NULL;
-}
-
-static void
-offscreen_window_to_parent (GdkWindow *offscreen_window,
- double offscreen_x,
- double offscreen_y,
- double *parent_x,
- double *parent_y,
- GtkMirrorBin *bin)
-{
- to_parent (bin, offscreen_x, offscreen_y, parent_x, parent_y);
-}
-
-static void
-offscreen_window_from_parent (GdkWindow *window,
- double parent_x,
- double parent_y,
- double *offscreen_x,
- double *offscreen_y,
- GtkMirrorBin *bin)
-{
- to_child (bin, parent_x, parent_y, offscreen_x, offscreen_y);
-}
-
-static void
-gtk_mirror_bin_realize (GtkWidget *widget)
-{
- GtkMirrorBin *bin = GTK_MIRROR_BIN (widget);
- GtkAllocation allocation;
- GdkWindow *window;
- GdkWindowAttr attributes;
- gint attributes_mask;
- GtkRequisition child_requisition;
-
- gtk_widget_set_realized (widget, TRUE);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- attributes.x = allocation.x;
- attributes.y = allocation.y;
- attributes.width = allocation.width;
- attributes.height = allocation.height;
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.event_mask = gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_POINTER_MOTION_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_SCROLL_MASK
- | GDK_ENTER_NOTIFY_MASK
- | GDK_LEAVE_NOTIFY_MASK;
-
- attributes.wclass = GDK_INPUT_OUTPUT;
-
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gtk_widget_set_window (widget, window);
- gdk_window_set_user_data (window, widget);
- g_signal_connect (window, "pick-embedded-child",
- G_CALLBACK (pick_offscreen_child), bin);
-
- attributes.window_type = GDK_WINDOW_OFFSCREEN;
-
- child_requisition.width = child_requisition.height = 0;
- if (bin->child && gtk_widget_get_visible (bin->child))
- {
- GtkAllocation child_allocation;
-
- gtk_widget_get_allocation (bin->child, &child_allocation);
- attributes.width = child_allocation.width;
- attributes.height = child_allocation.height;
- }
- bin->offscreen_window = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)),
- &attributes, attributes_mask);
- gdk_window_set_user_data (bin->offscreen_window, widget);
- if (bin->child)
- gtk_widget_set_parent_window (bin->child, bin->offscreen_window);
- gdk_offscreen_window_set_embedder (bin->offscreen_window, window);
- g_signal_connect (bin->offscreen_window, "to-embedder",
- G_CALLBACK (offscreen_window_to_parent), bin);
- g_signal_connect (bin->offscreen_window, "from-embedder",
- G_CALLBACK (offscreen_window_from_parent), bin);
-
- gdk_window_show (bin->offscreen_window);
-}
-
-static void
-gtk_mirror_bin_unrealize (GtkWidget *widget)
-{
- GtkMirrorBin *bin = GTK_MIRROR_BIN (widget);
-
- gdk_window_set_user_data (bin->offscreen_window, NULL);
- gdk_window_destroy (bin->offscreen_window);
- bin->offscreen_window = NULL;
-
- GTK_WIDGET_CLASS (gtk_mirror_bin_parent_class)->unrealize (widget);
-}
-
-static GType
-gtk_mirror_bin_child_type (GtkContainer *container)
-{
- GtkMirrorBin *bin = GTK_MIRROR_BIN (container);
-
- if (bin->child)
- return G_TYPE_NONE;
-
- return GTK_TYPE_WIDGET;
-}
-
-static void
-gtk_mirror_bin_add (GtkContainer *container,
- GtkWidget *widget)
-{
- GtkMirrorBin *bin = GTK_MIRROR_BIN (container);
-
- if (!bin->child)
- {
- gtk_widget_set_parent_window (widget, bin->offscreen_window);
- gtk_widget_set_parent (widget, GTK_WIDGET (bin));
- bin->child = widget;
- }
- else
- g_warning ("GtkMirrorBin cannot have more than one child");
-}
-
-static void
-gtk_mirror_bin_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- GtkMirrorBin *bin = GTK_MIRROR_BIN (container);
- gboolean was_visible;
-
- was_visible = gtk_widget_get_visible (widget);
-
- if (bin->child == widget)
- {
- gtk_widget_unparent (widget);
-
- bin->child = NULL;
-
- if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container)))
- gtk_widget_queue_resize (GTK_WIDGET (container));
- }
-}
-
-static void
-gtk_mirror_bin_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GtkMirrorBin *bin = GTK_MIRROR_BIN (container);
-
- g_return_if_fail (callback != NULL);
-
- if (bin->child)
- (*callback) (bin->child, callback_data);
-}
-
-static void
-gtk_mirror_bin_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GtkMirrorBin *bin = GTK_MIRROR_BIN (widget);
- GtkRequisition child_requisition;
-
- child_requisition.width = 0;
- child_requisition.height = 0;
-
- if (bin->child && gtk_widget_get_visible (bin->child))
- gtk_widget_get_preferred_size ( (bin->child),
- &child_requisition, NULL);
-
- requisition->width = child_requisition.width + 10;
- requisition->height = child_requisition.height * 2 + 10;
-}
-
-static void
-gtk_mirror_bin_measure (GtkWidget *widget,
- GtkOrientation orientation,
- int for_size,
- int *minimum,
- int *natural,
- int *minimum_baseline,
- int *natural_baseline)
-{
- GtkRequisition requisition;
-
- gtk_mirror_bin_size_request (widget, &requisition);
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- *minimum = *natural = requisition.width;
- else
- *minimum = *natural = requisition.height;
-}
-
-static void
-gtk_mirror_bin_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GtkMirrorBin *bin = GTK_MIRROR_BIN (widget);
- gint w, h;
-
- gtk_widget_set_allocation (widget, allocation);
-
- w = allocation->width;
- h = allocation->height;
-
- if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (gtk_widget_get_window (widget),
- allocation->x,
- allocation->y,
- w, h);
-
- if (bin->child && gtk_widget_get_visible (bin->child))
- {
- GtkRequisition child_requisition;
- GtkAllocation child_allocation;
-
- gtk_widget_get_preferred_size (bin->child,
- &child_requisition, NULL);
- child_allocation.x = 0;
- child_allocation.y = 0;
- child_allocation.height = child_requisition.height;
- child_allocation.width = child_requisition.width;
-
- if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (bin->offscreen_window,
- allocation->x,
- allocation->y,
- child_allocation.width, child_allocation.height);
- gtk_widget_size_allocate (bin->child, &child_allocation);
- }
-}
-
-static gboolean
-gtk_mirror_bin_damage (GtkWidget *widget,
- GdkEventExpose *event)
-{
- gdk_window_invalidate_rect (gtk_widget_get_window (widget),
- NULL, FALSE);
-
- return TRUE;
-}
-
-static gboolean
-gtk_mirror_bin_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- GtkMirrorBin *bin = GTK_MIRROR_BIN (widget);
- GdkWindow *window;
-
- window = gtk_widget_get_window (widget);
- if (gtk_cairo_should_draw_window (cr, window))
- {
- cairo_surface_t *surface;
- cairo_matrix_t matrix;
- cairo_pattern_t *mask;
- int height;
-
- if (bin->child && gtk_widget_get_visible (bin->child))
- {
- surface = gdk_offscreen_window_get_surface (bin->offscreen_window);
- height = gdk_window_get_height (bin->offscreen_window);
-
- /* paint the offscreen child */
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_paint (cr);
-
- cairo_matrix_init (&matrix, 1.0, 0.0, 0.3, 1.0, 0.0, 0.0);
- cairo_matrix_scale (&matrix, 1.0, -1.0);
- cairo_matrix_translate (&matrix, -10, - 3 * height - 10);
- cairo_transform (cr, &matrix);
-
- cairo_set_source_surface (cr, surface, 0, height);
-
- /* create linear gradient as mask-pattern to fade out the source */
- mask = cairo_pattern_create_linear (0.0, height, 0.0, 2*height);
- cairo_pattern_add_color_stop_rgba (mask, 0.0, 0.0, 0.0, 0.0, 0.0);
- cairo_pattern_add_color_stop_rgba (mask, 0.25, 0.0, 0.0, 0.0, 0.01);
- cairo_pattern_add_color_stop_rgba (mask, 0.5, 0.0, 0.0, 0.0, 0.25);
- cairo_pattern_add_color_stop_rgba (mask, 0.75, 0.0, 0.0, 0.0, 0.5);
- cairo_pattern_add_color_stop_rgba (mask, 1.0, 0.0, 0.0, 0.0, 1.0);
-
- /* paint the reflection */
- cairo_mask (cr, mask);
-
- cairo_pattern_destroy (mask);
- }
- }
- else if (gtk_cairo_should_draw_window (cr, bin->offscreen_window))
- {
- gtk_render_background (gtk_widget_get_style_context (widget),
- cr,
- 0, 0,
- gdk_window_get_width (bin->offscreen_window),
- gdk_window_get_height (bin->offscreen_window));
-
- if (bin->child)
- gtk_container_propagate_draw (GTK_CONTAINER (widget),
- bin->child,
- cr);
- }
-
- return FALSE;
-}
-
-/*** ***/
-
-GtkWidget *
-do_offscreen_window2 (GtkWidget *do_widget)
-{
- static GtkWidget *window = NULL;
-
- if (!window)
- {
- GtkWidget *bin, *vbox;
- GtkWidget *hbox, *entry, *applybutton, *backbutton;
- GtkSizeGroup *group;
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_screen (GTK_WINDOW (window),
- gtk_widget_get_screen (do_widget));
- gtk_window_set_title (GTK_WINDOW (window), "Effects");
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-
- bin = gtk_mirror_bin_new ();
-
- group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- backbutton = gtk_button_new ();
- gtk_container_add (GTK_CONTAINER (backbutton),
- gtk_image_new_from_icon_name ("go-previous", 4));
- gtk_size_group_add_widget (group, backbutton);
- entry = gtk_entry_new ();
- gtk_size_group_add_widget (group, entry);
- applybutton = gtk_button_new_with_label (_("Apply"));
- gtk_size_group_add_widget (group, applybutton);
-
- gtk_container_add (GTK_CONTAINER (window), vbox);
- gtk_box_pack_start (GTK_BOX (vbox), bin, TRUE, TRUE);
- gtk_container_add (GTK_CONTAINER (bin), hbox);
- gtk_box_pack_start (GTK_BOX (hbox), backbutton, FALSE, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE);
- gtk_box_pack_start (GTK_BOX (hbox), applybutton, FALSE, FALSE);
- }
-
- if (!gtk_widget_get_visible (window))
- gtk_widget_show_all (window);
- else
- gtk_widget_destroy (window);
-
- return window;
-}
gdk_window_set_event_compression
<SUBSECTION>
-gdk_offscreen_window_get_surface
-gdk_offscreen_window_set_embedder
-gdk_offscreen_window_get_embedder
-gdk_window_geometry_changed
gdk_window_coords_from_parent
gdk_window_coords_to_parent
-gdk_window_get_effective_parent
-gdk_window_get_effective_toplevel
<SUBSECTION Standard>
GDK_WINDOW
<xi:include href="xml/gtkaboutdialog.xml" />
<xi:include href="xml/gtkassistant.xml" />
<xi:include href="xml/gtkinvisible.xml" />
- <xi:include href="xml/gtkoffscreenwindow.xml" />
<xi:include href="xml/gtkwindowgroup.xml" />
</chapter>
GtkNotebookPrivate
</SECTION>
-<SECTION>
-<FILE>gtkoffscreenwindow</FILE>
-<TITLE>GtkOffscreenWindow</TITLE>
-GtkOffscreenWindow
-GtkOffscreenWindowClass
-gtk_offscreen_window_new
-gtk_offscreen_window_get_surface
-gtk_offscreen_window_get_pixbuf
-<SUBSECTION Standard>
-GTK_OFFSCREEN_WINDOW
-GTK_IS_OFFSCREEN_WINDOW
-GTK_TYPE_OFFSCREEN_WINDOW
-GTK_OFFSCREEN_WINDOW_CLASS
-GTK_IS_OFFSCREEN_WINDOW_CLASS
-GTK_OFFSCREEN_WINDOW_GET_CLASS
-
-<SUBSECTION Private>
-gtk_offscreen_window_get_type
-</SECTION>
-
<SECTION>
<FILE>gtkpaned</FILE>
<TITLE>GtkPaned</TITLE>
gdkkeys.c \
gdkkeyuni.c \
gdkmonitor.c \
- gdkoffscreenwindow.c \
gdkframeclock.c \
gdkframeclockidle.c \
gdkpango.c \
/* drag and drop information */
GdkDragContext *current_dest_drag;
- /* The offscreen window that has the pointer in it (if any) */
- GdkWindow *active_offscreen_window;
-
GdkBroadwayServer *server;
gpointer move_resize_data;
static const cairo_user_data_key_t gdk_broadway_cairo_key;
#define WINDOW_IS_TOPLEVEL_OR_FOREIGN(window) \
- (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
- GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
+ (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD)
#define WINDOW_IS_TOPLEVEL(window) \
(GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
- GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \
- GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
+ GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
struct _GdkBroadwayWindow {
GdkWindow parent;
native = gdk_window_get_toplevel (window);
- while (native->window_type == GDK_WINDOW_OFFSCREEN)
- {
- native = gdk_offscreen_window_get_embedder (native);
-
- if (native == NULL ||
- (!_gdk_window_has_impl (native) &&
- !gdk_window_is_viewable (native)))
- return GDK_GRAB_NOT_VIEWABLE;
-
- native = gdk_window_get_toplevel (native);
- }
-
if (native == NULL || GDK_WINDOW_DESTROYED (native))
return GDK_GRAB_NOT_VIEWABLE;
gint shadow_right;
gint shadow_bottom;
- guint num_offscreen_children;
-
/* The clip region is the part of the window, in window coordinates
that is fully or partially (i.e. semi transparently) visible in
the window hierarchy from the toplevel and down */
gboolean _gdk_window_has_impl (GdkWindow *window);
GdkWindow * _gdk_window_get_impl_window (GdkWindow *window);
-/*****************************
- * offscreen window routines *
- *****************************/
-GType gdk_offscreen_window_get_type (void);
-void _gdk_offscreen_window_new (GdkWindow *window,
- GdkWindowAttr *attributes,
- gint attributes_mask);
-cairo_surface_t * _gdk_offscreen_window_create_surface (GdkWindow *window,
- gint width,
- gint height);
-
G_END_DECLS
#endif /* __GDK_INTERNALS_H__ */
+++ /dev/null
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2005. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#include "config.h"
-
-#include "gdkwindow.h"
-#include "gdkinternals.h"
-#include "gdkwindowimpl.h"
-
-#include <math.h>
-
-#include "fallback-c89.c"
-
-/* LIMITATIONS:
- *
- * Offscreen windows can’t be the child of a foreign window,
- * nor contain foreign windows
- * GDK_POINTER_MOTION_HINT_MASK isn't effective
- */
-
-typedef struct _GdkOffscreenWindow GdkOffscreenWindow;
-typedef struct _GdkOffscreenWindowClass GdkOffscreenWindowClass;
-
-struct _GdkOffscreenWindow
-{
- GdkWindowImpl parent_instance;
-
- GdkWindow *wrapper;
-
- cairo_surface_t *surface;
- GdkWindow *embedder;
-};
-
-struct _GdkOffscreenWindowClass
-{
- GdkWindowImplClass parent_class;
-};
-
-#define GDK_TYPE_OFFSCREEN_WINDOW (gdk_offscreen_window_get_type())
-#define GDK_OFFSCREEN_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_OFFSCREEN_WINDOW, GdkOffscreenWindow))
-#define GDK_IS_OFFSCREEN_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_OFFSCREEN_WINDOW))
-#define GDK_OFFSCREEN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_OFFSCREEN_WINDOW, GdkOffscreenWindowClass))
-#define GDK_IS_OFFSCREEN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_OFFSCREEN_WINDOW))
-#define GDK_OFFSCREEN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_OFFSCREEN_WINDOW, GdkOffscreenWindowClass))
-
-static void gdk_offscreen_window_hide (GdkWindow *window);
-
-G_DEFINE_TYPE (GdkOffscreenWindow, gdk_offscreen_window, GDK_TYPE_WINDOW_IMPL)
-
-
-static void
-gdk_offscreen_window_finalize (GObject *object)
-{
- GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (object);
-
- if (offscreen->surface)
- cairo_surface_destroy (offscreen->surface);
-
- G_OBJECT_CLASS (gdk_offscreen_window_parent_class)->finalize (object);
-}
-
-static void
-gdk_offscreen_window_init (GdkOffscreenWindow *window)
-{
-}
-
-static void
-gdk_offscreen_window_destroy (GdkWindow *window,
- gboolean recursing,
- gboolean foreign_destroy)
-{
- gdk_offscreen_window_set_embedder (window, NULL);
-
- if (!recursing)
- gdk_offscreen_window_hide (window);
-}
-
-static cairo_surface_t *
-get_surface (GdkOffscreenWindow *offscreen)
-{
- if (! offscreen->surface)
- {
- GdkWindow *window = offscreen->wrapper;
-
- g_signal_emit_by_name (window, "create-surface",
- window->width,
- window->height,
- &offscreen->surface);
- }
-
- return offscreen->surface;
-}
-
-static gboolean
-is_parent_of (GdkWindow *parent,
- GdkWindow *child)
-{
- GdkWindow *w;
-
- w = child;
- while (w != NULL)
- {
- if (w == parent)
- return TRUE;
-
- w = gdk_window_get_parent (w);
- }
-
- return FALSE;
-}
-
-static cairo_surface_t *
-gdk_offscreen_window_ref_cairo_surface (GdkWindow *window)
-{
- GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
-
- return cairo_surface_reference (get_surface (offscreen));
-}
-
-cairo_surface_t *
-_gdk_offscreen_window_create_surface (GdkWindow *offscreen,
- gint width,
- gint height)
-{
- GdkOffscreenWindow *impl;
- GdkWindow *derived;
-
- g_return_val_if_fail (GDK_IS_OFFSCREEN_WINDOW (offscreen->impl), NULL);
-
- impl = GDK_OFFSCREEN_WINDOW (offscreen->impl);
- derived = impl->embedder ? impl->embedder : offscreen->parent;
-
- return gdk_window_create_similar_surface (derived,
- CAIRO_CONTENT_COLOR_ALPHA,
- width, height);
-}
-
-void
-_gdk_offscreen_window_new (GdkWindow *window,
- GdkWindowAttr *attributes,
- gint attributes_mask)
-{
- GdkOffscreenWindow *offscreen;
-
- g_return_if_fail (attributes != NULL);
-
- if (attributes->wclass != GDK_INPUT_OUTPUT)
- return; /* Can't support input only offscreens */
-
- if (window->parent != NULL && GDK_WINDOW_DESTROYED (window->parent))
- return;
-
- window->impl = g_object_new (GDK_TYPE_OFFSCREEN_WINDOW, NULL);
- offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
- offscreen->wrapper = window;
-}
-
-static gboolean
-gdk_offscreen_window_reparent (GdkWindow *window,
- GdkWindow *new_parent,
- gint x,
- gint y)
-{
- GdkWindow *old_parent;
- gboolean was_mapped;
-
- if (new_parent)
- {
- /* No input-output children of input-only windows */
- if (new_parent->input_only && !window->input_only)
- return FALSE;
-
- /* Don't create loops in hierarchy */
- if (is_parent_of (window, new_parent))
- return FALSE;
- }
-
- was_mapped = GDK_WINDOW_IS_MAPPED (window);
-
- gdk_window_hide (window);
-
- if (window->parent)
- window->parent->children = g_list_remove_link (window->parent->children, &window->children_list_node);
-
- old_parent = window->parent;
- window->parent = new_parent;
- window->x = x;
- window->y = y;
-
- if (new_parent)
- window->parent->children = g_list_concat (&window->children_list_node, window->parent->children);
-
- _gdk_synthesize_crossing_events_for_geometry_change (window);
- if (old_parent)
- _gdk_synthesize_crossing_events_for_geometry_change (old_parent);
-
- return was_mapped;
-}
-
-static void
-gdk_offscreen_window_set_device_cursor (GdkWindow *window,
- GdkDevice *device,
- GdkCursor *cursor)
-{
-}
-
-static void
-from_embedder (GdkWindow *window,
- double embedder_x, double embedder_y,
- double *offscreen_x, double *offscreen_y)
-{
- g_signal_emit_by_name (window->impl_window,
- "from-embedder",
- embedder_x, embedder_y,
- offscreen_x, offscreen_y,
- NULL);
-}
-
-static void
-to_embedder (GdkWindow *window,
- double offscreen_x, double offscreen_y,
- double *embedder_x, double *embedder_y)
-{
- g_signal_emit_by_name (window->impl_window,
- "to-embedder",
- offscreen_x, offscreen_y,
- embedder_x, embedder_y,
- NULL);
-}
-
-static void
-gdk_offscreen_window_get_root_coords (GdkWindow *window,
- gint x,
- gint y,
- gint *root_x,
- gint *root_y)
-{
- GdkOffscreenWindow *offscreen;
- int tmpx, tmpy;
-
- tmpx = x;
- tmpy = y;
-
- offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
- if (offscreen->embedder)
- {
- double dx, dy;
- to_embedder (window,
- x, y,
- &dx, &dy);
- tmpx = floor (dx + 0.5);
- tmpy = floor (dy + 0.5);
- gdk_window_get_root_coords (offscreen->embedder,
- tmpx, tmpy,
- &tmpx, &tmpy);
-
- }
-
- if (root_x)
- *root_x = tmpx;
- if (root_y)
- *root_y = tmpy;
-}
-
-static gboolean
-gdk_offscreen_window_get_device_state (GdkWindow *window,
- GdkDevice *device,
- gdouble *x,
- gdouble *y,
- GdkModifierType *mask)
-{
- GdkOffscreenWindow *offscreen;
- double tmpx, tmpy;
- double dtmpx, dtmpy;
- GdkModifierType tmpmask;
-
- tmpx = 0;
- tmpy = 0;
- tmpmask = 0;
-
- offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
- if (offscreen->embedder != NULL)
- {
- gdk_window_get_device_position_double (offscreen->embedder, device, &tmpx, &tmpy, &tmpmask);
- from_embedder (window,
- tmpx, tmpy,
- &dtmpx, &dtmpy);
- tmpx = dtmpx;
- tmpy = dtmpy;
- }
-
- if (x)
- *x = round (tmpx);
- if (y)
- *y = round (tmpy);
- if (mask)
- *mask = tmpmask;
- return TRUE;
-}
-
-/**
- * gdk_offscreen_window_get_surface:
- * @window: a #GdkWindow
- *
- * Gets the offscreen surface that an offscreen window renders into.
- * If you need to keep this around over window resizes, you need to
- * add a reference to it.
- *
- * Returns: (nullable) (transfer none): The offscreen surface, or
- * %NULL if not offscreen
- */
-cairo_surface_t *
-gdk_offscreen_window_get_surface (GdkWindow *window)
-{
- GdkOffscreenWindow *offscreen;
-
- g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
-
- if (!GDK_IS_OFFSCREEN_WINDOW (window->impl))
- return NULL;
-
- offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
-
- return get_surface (offscreen);
-}
-
-static void
-gdk_offscreen_window_raise (GdkWindow *window)
-{
- /* gdk_window_raise already changed the stacking order */
- _gdk_synthesize_crossing_events_for_geometry_change (window);
-}
-
-static void
-gdk_offscreen_window_lower (GdkWindow *window)
-{
- /* gdk_window_lower already changed the stacking order */
- _gdk_synthesize_crossing_events_for_geometry_change (window);
-}
-
-static void
-gdk_offscreen_window_move_resize_internal (GdkWindow *window,
- gint x,
- gint y,
- gint width,
- gint height,
- gboolean send_expose_events)
-{
- GdkOffscreenWindow *offscreen;
-
- offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
-
- if (width < 1)
- width = 1;
- if (height < 1)
- height = 1;
-
- if (window->destroyed)
- return;
-
- window->x = x;
- window->y = y;
-
- if (window->width != width ||
- window->height != height)
- {
- window->width = width;
- window->height = height;
-
- if (offscreen->surface)
- {
- cairo_surface_t *old_surface;
- cairo_t *cr;
-
- old_surface = offscreen->surface;
- offscreen->surface = NULL;
-
- offscreen->surface = get_surface (offscreen);
-
- cr = cairo_create (offscreen->surface);
- cairo_set_source_surface (cr, old_surface, 0, 0);
- cairo_paint (cr);
- cairo_destroy (cr);
-
- cairo_surface_destroy (old_surface);
- }
- }
-
- if (GDK_WINDOW_IS_MAPPED (window))
- {
- /* TODO: Only invalidate new area, i.e. for larger windows */
- gdk_window_invalidate_rect (window, NULL, TRUE);
- _gdk_synthesize_crossing_events_for_geometry_change (window);
- }
-}
-
-static void
-gdk_offscreen_window_move_resize (GdkWindow *window,
- gboolean with_move,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- if (!with_move)
- {
- x = window->x;
- y = window->y;
- }
-
- if (width < 0)
- width = window->width;
-
- if (height < 0)
- height = window->height;
-
- gdk_offscreen_window_move_resize_internal (window,
- x, y, width, height,
- TRUE);
-}
-
-static void
-gdk_offscreen_window_show (GdkWindow *window,
- gboolean already_mapped)
-{
- GdkRectangle area = { 0, 0, window->width, window->height };
-
- gdk_window_invalidate_rect (window, &area, FALSE);
-}
-
-
-static void
-gdk_offscreen_window_hide (GdkWindow *window)
-{
- /* TODO: This needs updating to the new grab world */
-#if 0
- GdkOffscreenWindow *offscreen;
- GdkDisplay *display;
-
- g_return_if_fail (window != NULL);
-
- offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
-
- /* May need to break grabs on children */
- display = gdk_window_get_display (window);
-
- if (display->pointer_grab.window != NULL)
- {
- if (is_parent_of (window, display->pointer_grab.window))
- {
- /* Call this ourselves, even though gdk_display_pointer_ungrab
- does so too, since we want to pass implicit == TRUE so the
- broken grab event is generated */
- _gdk_display_unset_has_pointer_grab (display,
- TRUE,
- FALSE,
- GDK_CURRENT_TIME);
- gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME);
- }
- }
-#endif
-}
-
-static void
-gdk_offscreen_window_withdraw (GdkWindow *window)
-{
-}
-
-static GdkEventMask
-gdk_offscreen_window_get_events (GdkWindow *window)
-{
- return 0;
-}
-
-static void
-gdk_offscreen_window_set_events (GdkWindow *window,
- GdkEventMask event_mask)
-{
-}
-
-static void
-gdk_offscreen_window_shape_combine_region (GdkWindow *window,
- const cairo_region_t *shape_region,
- gint offset_x,
- gint offset_y)
-{
-}
-
-static void
-gdk_offscreen_window_input_shape_combine_region (GdkWindow *window,
- const cairo_region_t *shape_region,
- gint offset_x,
- gint offset_y)
-{
-}
-
-static void
-gdk_offscreen_window_get_geometry (GdkWindow *window,
- gint *x,
- gint *y,
- gint *width,
- gint *height)
-{
- if (!GDK_WINDOW_DESTROYED (window))
- {
- if (x)
- *x = window->x;
- if (y)
- *y = window->y;
- if (width)
- *width = window->width;
- if (height)
- *height = window->height;
- }
-}
-
-static void
-gdk_offscreen_window_queue_antiexpose (GdkWindow *window,
- cairo_region_t *area)
-{
-}
-
-/**
- * gdk_offscreen_window_set_embedder:
- * @window: a #GdkWindow
- * @embedder: the #GdkWindow that @window gets embedded in
- *
- * Sets @window to be embedded in @embedder.
- *
- * To fully embed an offscreen window, in addition to calling this
- * function, it is also necessary to handle the #GdkWindow::pick-embedded-child
- * signal on the @embedder and the #GdkWindow::to-embedder and
- * #GdkWindow::from-embedder signals on @window.
- *
- * Since: 2.18
- */
-void
-gdk_offscreen_window_set_embedder (GdkWindow *window,
- GdkWindow *embedder)
-{
- GdkOffscreenWindow *offscreen;
-
- g_return_if_fail (GDK_IS_WINDOW (window));
-
- if (!GDK_IS_OFFSCREEN_WINDOW (window->impl))
- return;
-
- offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
-
- if (embedder)
- {
- g_object_ref (embedder);
- embedder->num_offscreen_children++;
- }
-
- if (offscreen->embedder)
- {
- g_object_unref (offscreen->embedder);
- offscreen->embedder->num_offscreen_children--;
- }
-
- offscreen->embedder = embedder;
-}
-
-/**
- * gdk_offscreen_window_get_embedder:
- * @window: a #GdkWindow
- *
- * Gets the window that @window is embedded in.
- *
- * Returns: (nullable) (transfer none): the embedding #GdkWindow, or
- * %NULL if @window is not an mbedded offscreen window
- *
- * Since: 2.18
- */
-GdkWindow *
-gdk_offscreen_window_get_embedder (GdkWindow *window)
-{
- GdkOffscreenWindow *offscreen;
-
- g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
-
- if (!GDK_IS_OFFSCREEN_WINDOW (window->impl))
- return NULL;
-
- offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
-
- return offscreen->embedder;
-}
-
-static void
-gdk_offscreen_window_do_nothing (GdkWindow *window)
-{
-}
-
-static void
-gdk_offscreen_window_set_boolean (GdkWindow *window,
- gboolean setting)
-{
-}
-
-static void
-gdk_offscreen_window_set_string (GdkWindow *window,
- const gchar *setting)
-{
-}
-
-static void
-gdk_offscreen_window_set_list (GdkWindow *window,
- GList *list)
-{
-}
-
-static void
-gdk_offscreen_window_set_wmfunctions (GdkWindow *window,
- GdkWMFunction functions)
-{
-}
-
-static void
-gdk_offscreen_window_set_transient_for (GdkWindow *window,
- GdkWindow *another)
-{
-}
-
-static void
-gdk_offscreen_window_get_frame_extents (GdkWindow *window,
- GdkRectangle *rect)
-{
- rect->x = window->x;
- rect->y = window->y;
- rect->width = window->width;
- rect->height = window->height;
-}
-
-static gint
-gdk_offscreen_window_get_scale_factor (GdkWindow *window)
-{
- GdkOffscreenWindow *offscreen;
-
- if (GDK_WINDOW_DESTROYED (window))
- return 1;
-
- offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
- if (offscreen->embedder)
- return gdk_window_get_scale_factor (offscreen->embedder);
-
- return gdk_window_get_scale_factor (window->parent);
-}
-
-static void
-gdk_offscreen_window_set_opacity (GdkWindow *window, gdouble opacity)
-{
-}
-
-static gboolean
-gdk_offscreen_window_beep (GdkWindow *window)
-{
- return FALSE;
-}
-
-static void
-gdk_offscreen_window_class_init (GdkOffscreenWindowClass *klass)
-{
- GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass);
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = gdk_offscreen_window_finalize;
-
- impl_class->ref_cairo_surface = gdk_offscreen_window_ref_cairo_surface;
- impl_class->show = gdk_offscreen_window_show;
- impl_class->hide = gdk_offscreen_window_hide;
- impl_class->withdraw = gdk_offscreen_window_withdraw;
- impl_class->set_events = gdk_offscreen_window_set_events;
- impl_class->get_events = gdk_offscreen_window_get_events;
- impl_class->raise = gdk_offscreen_window_raise;
- impl_class->lower = gdk_offscreen_window_lower;
- impl_class->restack_under = NULL;
- impl_class->restack_toplevel = NULL;
- impl_class->move_resize = gdk_offscreen_window_move_resize;
- impl_class->reparent = gdk_offscreen_window_reparent;
- impl_class->set_device_cursor = gdk_offscreen_window_set_device_cursor;
- impl_class->get_geometry = gdk_offscreen_window_get_geometry;
- impl_class->get_root_coords = gdk_offscreen_window_get_root_coords;
- impl_class->get_device_state = gdk_offscreen_window_get_device_state;
- impl_class->shape_combine_region = gdk_offscreen_window_shape_combine_region;
- impl_class->input_shape_combine_region = gdk_offscreen_window_input_shape_combine_region;
- impl_class->queue_antiexpose = gdk_offscreen_window_queue_antiexpose;
- impl_class->destroy = gdk_offscreen_window_destroy;
- impl_class->destroy_foreign = NULL;
- impl_class->get_shape = NULL;
- impl_class->get_input_shape = NULL;
- impl_class->beep = gdk_offscreen_window_beep;
-
- impl_class->focus = NULL;
- impl_class->set_type_hint = NULL;
- impl_class->get_type_hint = NULL;
- impl_class->set_modal_hint = gdk_offscreen_window_set_boolean;
- impl_class->set_skip_taskbar_hint = gdk_offscreen_window_set_boolean;
- impl_class->set_skip_pager_hint = gdk_offscreen_window_set_boolean;
- impl_class->set_urgency_hint = gdk_offscreen_window_set_boolean;
- impl_class->set_geometry_hints = NULL;
- impl_class->set_title = gdk_offscreen_window_set_string;
- impl_class->set_role = gdk_offscreen_window_set_string;
- impl_class->set_startup_id = gdk_offscreen_window_set_string;
- impl_class->set_transient_for = gdk_offscreen_window_set_transient_for;
- impl_class->get_frame_extents = gdk_offscreen_window_get_frame_extents;
- impl_class->set_override_redirect = NULL;
- impl_class->set_accept_focus = gdk_offscreen_window_set_boolean;
- impl_class->set_focus_on_map = gdk_offscreen_window_set_boolean;
- impl_class->set_icon_list = gdk_offscreen_window_set_list;
- impl_class->set_icon_name = gdk_offscreen_window_set_string;
- impl_class->iconify = gdk_offscreen_window_do_nothing;
- impl_class->deiconify = gdk_offscreen_window_do_nothing;
- impl_class->stick = gdk_offscreen_window_do_nothing;
- impl_class->unstick = gdk_offscreen_window_do_nothing;
- impl_class->maximize = gdk_offscreen_window_do_nothing;
- impl_class->unmaximize = gdk_offscreen_window_do_nothing;
- impl_class->fullscreen = gdk_offscreen_window_do_nothing;
- impl_class->unfullscreen = gdk_offscreen_window_do_nothing;
- impl_class->set_keep_above = gdk_offscreen_window_set_boolean;
- impl_class->set_keep_below = gdk_offscreen_window_set_boolean;
- impl_class->get_group = NULL;
- impl_class->set_group = NULL;
- impl_class->set_decorations = NULL;
- impl_class->get_decorations = NULL;
- impl_class->set_functions = gdk_offscreen_window_set_wmfunctions;
- impl_class->begin_resize_drag = NULL;
- impl_class->begin_move_drag = NULL;
- impl_class->enable_synchronized_configure = gdk_offscreen_window_do_nothing;
- impl_class->configure_finished = NULL;
- impl_class->set_opacity = gdk_offscreen_window_set_opacity;
- impl_class->destroy_notify = NULL;
- impl_class->register_dnd = gdk_offscreen_window_do_nothing;
- impl_class->drag_begin = NULL;
- impl_class->sync_rendering = NULL;
- impl_class->simulate_key = NULL;
- impl_class->simulate_button = NULL;
- impl_class->get_property = NULL;
- impl_class->change_property = NULL;
- impl_class->delete_property = NULL;
- impl_class->get_scale_factor = gdk_offscreen_window_get_scale_factor;
-}
* window, the thing a user might think of as a “window” with a titlebar
* and so on; a #GtkWindow may contain many #GdkWindows. For example,
* each #GtkButton has a #GdkWindow associated with it.
- *
- * # Offscreen Windows # {#OFFSCREEN-WINDOWS}
- *
- * Offscreen windows are more general than composited windows, since
- * they allow not only to modify the rendering of the child window onto
- * its parent, but also to apply coordinate transformations.
- *
- * To integrate an offscreen window into a window hierarchy, one has
- * to call gdk_offscreen_window_set_embedder() and handle a number of
- * signals. The #GdkWindow::pick-embedded-child signal on the embedder
- * window is used to select an offscreen child at given coordinates,
- * and the #GdkWindow::to-embedder and #GdkWindow::from-embedder signals
- * on the offscreen window are used to translate coordinates between
- * the embedder and the offscreen window.
- *
- * For rendering an offscreen window onto its embedder, the contents
- * of the offscreen window are available as a surface, via
- * gdk_offscreen_window_get_surface().
*/
* and the actual platform specific implementation was in a delegate
* object available as “impl” in the window object.
*
- * With the addition of client side windows and offscreen windows this
- * changes a bit. The application-visible GdkWindow object behaves as
- * it did before, but not all such windows now have a corresponding native
- * window. Instead windows that are “client side” are emulated by the gdk
- * code such that clipping, drawing, moving, events etc work as expected.
+ * With the addition of client side windows this changes a bit. The
+ * application-visible GdkWindow object behaves as it did before, but
+ * not all such windows now have a corresponding native
+ * window. Instead windows that are “client side” are emulated by the
+ * gdk code such that clipping, drawing, moving, events etc work as
+ * expected.
*
* For GdkWindows that have a native window the “impl” object is the
* same as before. However, for all client side windows the impl object
* is shared with its parent (i.e. all client windows descendants of one
* native window has the same impl.
*
- * Additionally there is a new type of platform independent impl object,
- * GdkOffscreenWindow. All windows of type GDK_WINDOW_OFFSCREEN get an impl
- * of this type (while their children are generally GDK_WINDOW_CHILD virtual
- * windows). Such windows work by allocating a #cairo_surface_t as the backing
- * store for drawing operations, which is resized with the window.
- *
* GdkWindows have a pointer to the “impl window” they are in, i.e.
* the topmost GdkWindow which have the same “impl” value. This is stored
* in impl_window, which is different from the window itself only for client
* with respect to the impl window (abs_x, abs_y). We also track the clip
* region of the window wrt parent windows, in window-relative coordinates (clip_region).
*
- * All toplevel windows are native windows, but also child windows can be
- * native (although not children of offscreens). We always listen to
- * a basic set of events (see get_native_event_mask) for these windows
- * so that we can emulate events for any client side children.
+ * All toplevel windows are native windows, but also child windows can
+ * be native. We always listen to a basic set of events (see
+ * get_native_event_mask) for these windows so that we can emulate
+ * events for any client side children.
*
* For native windows we apply the calculated clip region as a window shape
* so that eg. client side siblings that overlap the native child properly
#define GDK_VISIBILITY_NOT_VIEWABLE 3
enum {
- PICK_EMBEDDED_CHILD, /* only called if children are embedded */
- TO_EMBEDDER,
- FROM_EMBEDDER,
- CREATE_SURFACE,
MOVED_TO_RECT,
LAST_SIGNAL
};
NULL, g_object_unref);
}
-/* Stop and return on the first non-NULL parent */
-static gboolean
-accumulate_get_window (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer data)
-{
- g_value_copy (handler_return, return_accu);
- /* Continue while returning NULL */
- return g_value_get_object (handler_return) == NULL;
-}
-
-static gboolean
-create_surface_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer data)
-{
- g_value_copy (handler_return, return_accu);
-
- /* Stop on the first non-NULL return value */
- return g_value_get_boxed (handler_return) == NULL;
-}
-
static GQuark quark_pointer_window = 0;
static void
object_class->set_property = gdk_window_set_property;
object_class->get_property = gdk_window_get_property;
- klass->create_surface = _gdk_offscreen_window_create_surface;
-
quark_pointer_window = g_quark_from_static_string ("gtk-pointer-window");
G_PARAM_READWRITE);
g_object_class_install_properties (object_class, LAST_PROP, properties);
- /**
- * GdkWindow::pick-embedded-child:
- * @window: the window on which the signal is emitted
- * @x: x coordinate in the window
- * @y: y coordinate in the window
- *
- * The ::pick-embedded-child signal is emitted to find an embedded
- * child at the given position.
- *
- * Returns: (nullable) (transfer none): the #GdkWindow of the
- * embedded child at @x, @y, or %NULL
- *
- * Since: 2.18
- */
- signals[PICK_EMBEDDED_CHILD] =
- g_signal_new (g_intern_static_string ("pick-embedded-child"),
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdkWindowClass, pick_embedded_child),
- accumulate_get_window, NULL,
- _gdk_marshal_OBJECT__DOUBLE_DOUBLE,
- GDK_TYPE_WINDOW,
- 2,
- G_TYPE_DOUBLE,
- G_TYPE_DOUBLE);
-
- /**
- * GdkWindow::to-embedder:
- * @window: the offscreen window on which the signal is emitted
- * @offscreen_x: x coordinate in the offscreen window
- * @offscreen_y: y coordinate in the offscreen window
- * @embedder_x: (out) (type double): return location for the x
- * coordinate in the embedder window
- * @embedder_y: (out) (type double): return location for the y
- * coordinate in the embedder window
- *
- * The ::to-embedder signal is emitted to translate coordinates
- * in an offscreen window to its embedder.
- *
- * See also #GdkWindow::from-embedder.
- *
- * Since: 2.18
- */
- signals[TO_EMBEDDER] =
- g_signal_new (g_intern_static_string ("to-embedder"),
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdkWindowClass, to_embedder),
- NULL, NULL,
- _gdk_marshal_VOID__DOUBLE_DOUBLE_POINTER_POINTER,
- G_TYPE_NONE,
- 4,
- G_TYPE_DOUBLE,
- G_TYPE_DOUBLE,
- G_TYPE_POINTER,
- G_TYPE_POINTER);
-
- /**
- * GdkWindow::from-embedder:
- * @window: the offscreen window on which the signal is emitted
- * @embedder_x: x coordinate in the embedder window
- * @embedder_y: y coordinate in the embedder window
- * @offscreen_x: (out) (type double): return location for the x
- * coordinate in the offscreen window
- * @offscreen_y: (out) (type double): return location for the y
- * coordinate in the offscreen window
- *
- * The ::from-embedder signal is emitted to translate coordinates
- * in the embedder of an offscreen window to the offscreen window.
- *
- * See also #GdkWindow::to-embedder.
- *
- * Since: 2.18
- */
- signals[FROM_EMBEDDER] =
- g_signal_new (g_intern_static_string ("from-embedder"),
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdkWindowClass, from_embedder),
- NULL, NULL,
- _gdk_marshal_VOID__DOUBLE_DOUBLE_POINTER_POINTER,
- G_TYPE_NONE,
- 4,
- G_TYPE_DOUBLE,
- G_TYPE_DOUBLE,
- G_TYPE_POINTER,
- G_TYPE_POINTER);
-
- /**
- * GdkWindow::create-surface:
- * @window: the offscreen window on which the signal is emitted
- * @width: the width of the offscreen surface to create
- * @height: the height of the offscreen surface to create
- *
- * The ::create-surface signal is emitted when an offscreen window
- * needs its surface (re)created, which happens either when the
- * window is first drawn to, or when the window is being
- * resized. The first signal handler that returns a non-%NULL
- * surface will stop any further signal emission, and its surface
- * will be used.
- *
- * Note that it is not possible to access the window's previous
- * surface from within any callback of this signal. Calling
- * gdk_offscreen_window_get_surface() will lead to a crash.
- *
- * Returns: the newly created #cairo_surface_t for the offscreen window
- *
- * Since: 3.0
- */
- signals[CREATE_SURFACE] =
- g_signal_new (g_intern_static_string ("create-surface"),
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdkWindowClass, create_surface),
- create_surface_accumulator, NULL,
- _gdk_marshal_BOXED__INT_INT,
- CAIRO_GOBJECT_TYPE_SURFACE,
- 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
/**
* GdkWindow::moved-to-rect:
* @window: the #GdkWindow that moved
}
}
-static gboolean
-gdk_window_is_offscreen (GdkWindow *window)
-{
- return window->window_type == GDK_WINDOW_OFFSCREEN;
-}
-
static GdkWindow *
gdk_window_get_impl_window (GdkWindow *window)
{
if (!GDK_WINDOW_IS_MAPPED (sibling) || sibling->input_only)
continue;
- /* Ignore offscreen children, as they don't draw in their parent and
- * don't take part in the clipping */
- if (gdk_window_is_offscreen (sibling))
- continue;
-
r.x = sibling->x;
r.y = sibling->y;
r.width = sibling->width;
if (!GDK_WINDOW_IS_MAPPED (child) || child->input_only)
continue;
- /* Ignore offscreen children, as they don't draw in their parent and
- * don't take part in the clipping */
- if (gdk_window_is_offscreen (child))
- continue;
-
r.x = child->x;
r.y = child->y;
r.width = child->width;
{
return
gdk_window_has_impl (window) &&
- /* Not for offscreens */
- !gdk_window_is_offscreen (window) &&
- /* or for non-shaped toplevels */
+ /* Not for non-shaped toplevels */
(!gdk_window_is_toplevel (window) ||
window->shape != NULL || window->applied_shape) &&
/* or for foreign windows */
{
case GDK_WINDOW_TOPLEVEL:
case GDK_WINDOW_TEMP:
- case GDK_WINDOW_OFFSCREEN:
if (GDK_WINDOW_TYPE (parent) != GDK_WINDOW_ROOT)
g_warning (G_STRLOC "Toplevel windows must be created as children of\n"
"of a window of type GDK_WINDOW_ROOT or GDK_WINDOW_FOREIGN");
if (window->parent->window_type == GDK_WINDOW_ROOT)
native = TRUE; /* Always use native windows for toplevels */
- if (gdk_window_is_offscreen (window))
- {
- _gdk_offscreen_window_new (window, attributes, attributes_mask);
- window->impl_window = window;
- }
- else if (native)
+ if (native)
{
event_mask = get_native_event_mask (window);
else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL;
break;
- case GDK_WINDOW_OFFSCREEN:
case GDK_WINDOW_TOPLEVEL:
case GDK_WINDOW_CHILD:
case GDK_WINDOW_TEMP:
* Tries to ensure that there is a window-system native window for this
* GdkWindow. This may fail in some situations, returning %FALSE.
*
- * Offscreen window and children of them can never have native windows.
- *
* Some backends may not support native child windows.
*
* Returns: %TRUE if the window has a native window, %FALSE otherwise
impl_window = gdk_window_get_impl_window (window);
- if (gdk_window_is_offscreen (impl_window))
- return FALSE; /* native in offscreens not supported */
-
if (impl_window == window)
- /* Already has an impl, and its not offscreen . */
+ /* Already has an impl. */
return TRUE;
/* Need to create a native window */
case GDK_WINDOW_CHILD:
case GDK_WINDOW_TEMP:
case GDK_WINDOW_FOREIGN:
- case GDK_WINDOW_OFFSCREEN:
if (window->window_type == GDK_WINDOW_FOREIGN && !foreign_destroy)
{
/* Logically, it probably makes more sense to send
return GDK_WINDOW_DESTROYED (window);
}
-static void
-to_embedder (GdkWindow *window,
- gdouble offscreen_x,
- gdouble offscreen_y,
- gdouble *embedder_x,
- gdouble *embedder_y)
-{
- g_signal_emit (window, signals[TO_EMBEDDER], 0,
- offscreen_x, offscreen_y,
- embedder_x, embedder_y);
-}
-
-static void
-from_embedder (GdkWindow *window,
- gdouble embedder_x,
- gdouble embedder_y,
- gdouble *offscreen_x,
- gdouble *offscreen_y)
-{
- g_signal_emit (window, signals[FROM_EMBEDDER], 0,
- embedder_x, embedder_y,
- offscreen_x, offscreen_y);
-}
-
/**
* gdk_window_has_native:
* @window: a #GdkWindow
* matter for toplevel windows, because the window manager may choose
* to reparent them.
*
- * Note that you should use gdk_window_get_effective_parent() when
- * writing generic code that walks up a window hierarchy, because
- * gdk_window_get_parent() will most likely not do what you expect if
- * there are offscreen windows in the hierarchy.
- *
* Returns: (transfer none): parent of @window
**/
GdkWindow*
return window->parent;
}
-/**
- * gdk_window_get_effective_parent:
- * @window: a #GdkWindow
- *
- * Obtains the parent of @window, as known to GDK. Works like
- * gdk_window_get_parent() for normal windows, but returns the
- * window’s embedder for offscreen windows.
- *
- * See also: gdk_offscreen_window_get_embedder()
- *
- * Returns: (transfer none): effective parent of @window
- *
- * Since: 2.22
- **/
-GdkWindow *
-gdk_window_get_effective_parent (GdkWindow *window)
-{
- g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
-
- if (gdk_window_is_offscreen (window))
- return gdk_offscreen_window_get_embedder (window);
- else
- return window->parent;
-}
-
/**
* gdk_window_get_toplevel:
* @window: a #GdkWindow
* toplevel window, as is a %GDK_WINDOW_CHILD window that
* has a root window as parent.
*
- * Note that you should use gdk_window_get_effective_toplevel() when
- * you want to get to a window’s toplevel as seen on screen, because
- * gdk_window_get_toplevel() will most likely not do what you expect
- * if there are offscreen windows in the hierarchy.
- *
* Returns: (transfer none): the toplevel window containing @window
**/
GdkWindow *
return window;
}
-/**
- * gdk_window_get_effective_toplevel:
- * @window: a #GdkWindow
- *
- * Gets the toplevel window that’s an ancestor of @window.
- *
- * Works like gdk_window_get_toplevel(), but treats an offscreen window's
- * embedder as its parent, using gdk_window_get_effective_parent().
- *
- * See also: gdk_offscreen_window_get_embedder()
- *
- * Returns: (transfer none): the effective toplevel window containing @window
- *
- * Since: 2.22
- **/
-GdkWindow *
-gdk_window_get_effective_toplevel (GdkWindow *window)
-{
- GdkWindow *parent;
-
- g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
-
- while ((parent = gdk_window_get_effective_parent (window)) != NULL &&
- (gdk_window_get_window_type (parent) != GDK_WINDOW_ROOT))
- window = parent;
-
- return window;
-}
-
/**
* gdk_window_get_children:
* @window: a #GdkWindow
GDK_FRAME_CLOCK_PHASE_PAINT);
}
-static void
-gdk_window_add_damage (GdkWindow *toplevel,
- cairo_region_t *damaged_region)
-{
- GdkDisplay *display;
- GdkEvent event = { 0, };
-
- /* This function only makes sense for offscreen windows. */
- g_assert (gdk_window_is_offscreen (toplevel));
-
- event.expose.type = GDK_DAMAGE;
- event.expose.window = toplevel;
- event.expose.send_event = FALSE;
- event.expose.region = damaged_region;
- cairo_region_get_extents (event.expose.region, &event.expose.area);
-
- display = gdk_window_get_display (event.expose.window);
- _gdk_event_queue_append (display, gdk_event_copy (&event));
-}
-
static void
_gdk_window_process_updates_recurse_helper (GdkWindow *window,
cairo_region_t *expose_region)
if (cairo_region_is_empty (clipped_expose_region))
goto out;
- if (gdk_window_is_offscreen (window))
- gdk_window_add_damage (window, clipped_expose_region);
-
/* Paint the window before the children, clipped to the window region */
/* While gtk+ no longer handles exposes on anything but native
if (child->destroyed || !GDK_WINDOW_IS_MAPPED (child) || child->input_only)
continue;
- /* Ignore offscreen children, as they don't draw in their parent and
- * don't take part in the clipping */
- if (gdk_window_is_offscreen (child))
- continue;
-
/* Client side child, expose */
if (child->impl == window->impl)
{
native = gdk_window_get_toplevel (window);
- while (gdk_window_is_offscreen (native))
- {
- native = gdk_offscreen_window_get_embedder (native);
-
- if (native == NULL ||
- (!_gdk_window_has_impl (native) &&
- !gdk_window_is_viewable (native)))
- return;
-
- native = gdk_window_get_toplevel (native);
- }
-
device_mask = get_native_device_event_mask (window, device);
GDK_DEVICE_GET_CLASS (device)->select_window_events (device, native, device_mask);
}
* in parent’s coordinate system, or %NULL
*
* Transforms window coordinates from a child window to its parent
- * window, where the parent window is the normal parent as returned by
- * gdk_window_get_parent() for normal windows, and the window's
- * embedder as returned by gdk_offscreen_window_get_embedder() for
- * offscreen windows.
- *
- * For normal windows, calling this function is equivalent to adding
- * the return values of gdk_window_get_position() to the child coordinates.
- * For offscreen windows however (which can be arbitrarily transformed),
- * this function calls the GdkWindow::to-embedder: signal to translate
- * the coordinates.
- *
- * You should always use this function when writing generic code that
- * walks up a window hierarchy.
+ * window. Calling this function is equivalent to adding the return
+ * values of gdk_window_get_position() to the child coordinates.
*
* See also: gdk_window_coords_from_parent()
*
{
g_return_if_fail (GDK_IS_WINDOW (window));
- if (gdk_window_is_offscreen (window))
- {
- gdouble px, py;
-
- to_embedder (window, x, y, &px, &py);
+ if (parent_x)
+ *parent_x = x + window->x;
- if (parent_x)
- *parent_x = px;
-
- if (parent_y)
- *parent_y = py;
- }
- else
- {
- if (parent_x)
- *parent_x = x + window->x;
-
- if (parent_y)
- *parent_y = y + window->y;
- }
+ if (parent_y)
+ *parent_y = y + window->y;
}
/**
* @y: (out) (allow-none): return location for Y coordinate in child’s coordinate system
*
* Transforms window coordinates from a parent window to a child
- * window, where the parent window is the normal parent as returned by
- * gdk_window_get_parent() for normal windows, and the window's
- * embedder as returned by gdk_offscreen_window_get_embedder() for
- * offscreen windows.
- *
- * For normal windows, calling this function is equivalent to subtracting
- * the return values of gdk_window_get_position() from the parent coordinates.
- * For offscreen windows however (which can be arbitrarily transformed),
- * this function calls the GdkWindow::from-embedder: signal to translate
- * the coordinates.
+ * window.
*
- * You should always use this function when writing generic code that
- * walks down a window hierarchy.
+ * Calling this function is equivalent to subtracting the return
+ * values of gdk_window_get_position() from the parent coordinates.
*
* See also: gdk_window_coords_to_parent()
*
{
g_return_if_fail (GDK_IS_WINDOW (window));
- if (gdk_window_is_offscreen (window))
- {
- gdouble cx, cy;
-
- from_embedder (window, parent_x, parent_y, &cx, &cy);
-
- if (x)
- *x = cx;
-
- if (y)
- *y = cy;
- }
- else
- {
- if (x)
- *x = parent_x - window->x;
+ if (x)
+ *x = parent_x - window->x;
- if (y)
- *y = parent_y - window->y;
- }
+ if (y)
+ *y = parent_y - window->y;
}
/**
return window->shaped;
}
-/* Gets the toplevel for a window as used for events,
- i.e. including offscreen parents */
-static GdkWindow *
-get_event_parent (GdkWindow *window)
-{
- if (gdk_window_is_offscreen (window))
- return gdk_offscreen_window_get_embedder ((GdkWindow *)window);
- else
- return window->parent;
-}
-
/* Gets the toplevel for a window as used for events,
i.e. including offscreen parents going up to the native
toplevel */
{
GdkWindow *parent;
- while ((parent = get_event_parent (window)) != NULL &&
+ while ((parent = window->parent) != NULL &&
(parent->window_type != GDK_WINDOW_ROOT))
window = parent;
if (w == parent)
return TRUE;
- w = get_event_parent (w);
+ w = w->parent;
}
return FALSE;
the cursor is inherited from the parent */
while (cursor_window->cursor == NULL &&
!g_hash_table_contains (cursor_window->device_cursor, device) &&
- (parent = get_event_parent (cursor_window)) != NULL &&
+ (parent = cursor_window->parent) != NULL &&
parent->window_type != GDK_WINDOW_ROOT)
cursor_window = parent;
y = toplevel_y;
children = NULL;
- while ((parent = get_event_parent (window)) != NULL &&
+ while ((parent = window->parent) != NULL &&
(parent->window_type != GDK_WINDOW_ROOT))
{
children = g_list_prepend (children, window);
*window_y = y;
}
-static GdkWindow *
-pick_embedded_child (GdkWindow *window,
- gdouble x,
- gdouble y)
-{
- GdkWindow *res;
-
- res = NULL;
- g_signal_emit (window,
- signals[PICK_EMBEDDED_CHILD], 0,
- x, y, &res);
-
- return res;
-}
-
GdkWindow *
_gdk_window_find_child_at (GdkWindow *window,
double x,
NULL, NULL, NULL))
return (GdkWindow *)sub;
}
-
- if (window->num_offscreen_children > 0)
- {
- sub = pick_embedded_child (window,
- x, y);
- if (sub)
- return (GdkWindow *)sub;
- }
}
return NULL;
break;
}
}
- if (!found &&
- window->num_offscreen_children > 0)
- {
- sub = pick_embedded_child (window,
- x, y);
- if (sub)
- {
- found = TRUE;
- window = sub;
- from_embedder (sub, x, y, &x, &y);
- }
- }
}
while (found);
}
while (tmp != NULL && tmp->window_type != GDK_WINDOW_ROOT)
{
path1 = g_list_prepend (path1, tmp);
- tmp = get_event_parent (tmp);
+ tmp = tmp->parent;
}
tmp = win2;
while (tmp != NULL && tmp->window_type != GDK_WINDOW_ROOT)
{
path2 = g_list_prepend (path2, tmp);
- tmp = get_event_parent (tmp);
+ tmp = tmp->parent;
}
list1 = path1;
notify_type = GDK_NOTIFY_VIRTUAL;
last = a;
- win = get_event_parent (a);
+ win = a->parent;
while (win != c && win->window_type != GDK_WINDOW_ROOT)
{
send_crossing_event (display, toplevel,
serial);
last = win;
- win = get_event_parent (win);
+ win = win->parent;
}
}
}
if (c != b)
{
path = NULL;
- win = get_event_parent (b);
+ win = b->parent;
while (win != c && win->window_type != GDK_WINDOW_ROOT)
{
path = g_list_prepend (path, win);
- win = get_event_parent (win);
+ win = win->parent;
}
if (non_linear)
_gdk_display_enable_motion_hints (display, device);
}
-/**
- * gdk_window_geometry_changed:
- * @window: an embedded offscreen #GdkWindow
- *
- * This function informs GDK that the geometry of an embedded
- * offscreen window has changed. This is necessary for GDK to keep
- * track of which offscreen window the pointer is in.
- *
- * Since: 2.18
- */
-void
-gdk_window_geometry_changed (GdkWindow *window)
-{
- _gdk_synthesize_crossing_events_for_geometry_change (window);
-}
-
static void
source_events_device_added (GdkDeviceManager *device_manager,
GdkDevice *device,
return pointer_window;
}
- pointer_window = get_event_parent (pointer_window);
+ pointer_window = pointer_window->parent;
}
if (grab != NULL &&
/* Find the event window, that gets the grab */
w = pointer_window;
while (w != NULL &&
- (parent = get_event_parent (w)) != NULL &&
+ (parent = w->parent) != NULL &&
parent->window_type != GDK_WINDOW_ROOT)
{
if (w->event_mask & GDK_BUTTON_PRESS_MASK &&
"dialog",
"temp",
"foreign",
- "offscreen"
+ "subsurface"
};
g_print ("%*s%p: [%s] %d,%d %dx%d", indent, "", window,
* @GDK_WINDOW_TEMP: override redirect temporary window (used to implement
* #GtkMenu)
* @GDK_WINDOW_FOREIGN: foreign window (see gdk_window_foreign_new())
- * @GDK_WINDOW_OFFSCREEN: offscreen window (see
- * [Offscreen Windows][OFFSCREEN-WINDOWS]). Since 2.18
* @GDK_WINDOW_SUBSURFACE: subsurface-based window; This window is visually
* tied to a toplevel, and is moved/stacked with it. Currently this window
* type is only implemented in Wayland. Since 3.14
GDK_WINDOW_CHILD,
GDK_WINDOW_TEMP,
GDK_WINDOW_FOREIGN,
- GDK_WINDOW_OFFSCREEN,
GDK_WINDOW_SUBSURFACE
} GdkWindowType;
{
GObjectClass parent_class;
- GdkWindow * (* pick_embedded_child) (GdkWindow *window,
- gdouble x,
- gdouble y);
-
- /* the following 3 signals will only be emitted by offscreen windows */
- void (* to_embedder) (GdkWindow *window,
- gdouble offscreen_x,
- gdouble offscreen_y,
- gdouble *embedder_x,
- gdouble *embedder_y);
- void (* from_embedder) (GdkWindow *window,
- gdouble embedder_x,
- gdouble embedder_y,
- gdouble *offscreen_x,
- gdouble *offscreen_y);
- cairo_surface_t * (* create_surface) (GdkWindow *window,
- gint width,
- gint height);
-
/* Padding for future expansion */
void (*_gdk_reserved1) (void);
void (*_gdk_reserved2) (void);
GDK_AVAILABLE_IN_ALL
GdkWindow * gdk_window_get_toplevel (GdkWindow *window);
-GDK_AVAILABLE_IN_ALL
-GdkWindow * gdk_window_get_effective_parent (GdkWindow *window);
-GDK_AVAILABLE_IN_ALL
-GdkWindow * gdk_window_get_effective_toplevel (GdkWindow *window);
-
GDK_AVAILABLE_IN_ALL
GList * gdk_window_get_children (GdkWindow *window);
GDK_AVAILABLE_IN_ALL
GDK_AVAILABLE_IN_ALL
GdkWindow *gdk_get_default_root_window (void);
-/* Offscreen redirection */
-GDK_AVAILABLE_IN_ALL
-cairo_surface_t *
- gdk_offscreen_window_get_surface (GdkWindow *window);
-GDK_AVAILABLE_IN_ALL
-void gdk_offscreen_window_set_embedder (GdkWindow *window,
- GdkWindow *embedder);
-GDK_AVAILABLE_IN_ALL
-GdkWindow *gdk_offscreen_window_get_embedder (GdkWindow *window);
-GDK_AVAILABLE_IN_ALL
-void gdk_window_geometry_changed (GdkWindow *window);
-
/* Multidevice support */
GDK_AVAILABLE_IN_ALL
void gdk_window_set_support_multidevice (GdkWindow *window,
gdouble xf = x;
gdouble yf = y;
- while ((parent = gdk_window_get_effective_parent (window)) != NULL &&
+ while ((parent = window->parent) != NULL &&
(gdk_window_get_window_type (parent) != GDK_WINDOW_ROOT))
{
gdk_window_coords_to_parent (window, xf, yf, &xf, &yf);
gdkkeys.obj \
gdkkeyuni.obj \
gdkmarshalers.obj \
- gdkoffscreenwindow.obj \
gdkpango.obj \
gdkpixbuf-drawable.obj \
gdkrectangle.obj \
{
real_rect = *rect;
- while (parent && !gdk_window_has_native (parent) && gdk_window_get_effective_parent (parent))
+ while (parent && !gdk_window_has_native (parent) && gdk_window_get_parent (parent))
{
real_rect.left += parent->x;
real_rect.top += parent->y;
- parent = gdk_window_get_effective_parent (parent);
+ parent = gdk_window_get_parent (parent);
}
}
else
*x -= tmp_x;
*y -= tmp_y;
- current = gdk_window_get_effective_parent (current);
+ current = gdk_window_get_parent (current);
}
}
return NULL;
}
- toplevel = gdk_window_get_effective_toplevel (window);
+ toplevel = gdk_window_get_toplevel (window);
if (mask)
*mask = _gdk_quartz_events_get_current_keyboard_modifiers () |
#define WINDOW_IS_TOPLEVEL(window) \
(GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
- GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \
- GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
+ GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
/* This is the window corresponding to the key window */
static GdkWindow *current_keyboard_window;
grab = _gdk_display_get_last_device_grab (display, device);
if (grab && grab->window && !grab->owner_events)
{
- window = gdk_window_get_effective_toplevel (grab->window);
+ window = gdk_window_get_toplevel (grab->window);
break;
}
}
/* Finally check the grab window. */
GdkWindow *grab_toplevel;
- grab_toplevel = gdk_window_get_effective_toplevel (grab->window);
+ grab_toplevel = gdk_window_get_toplevel (grab->window);
get_window_point_from_screen_point (grab_toplevel, screen_point,
x, y);
windows = gdk_screen_get_toplevel_windows (screen);
for (list = windows; list; list = list->next)
- {
- if (GDK_WINDOW_TYPE(list->data) == GDK_WINDOW_OFFSCREEN)
- continue;
- _gdk_quartz_window_update_position (list->data);
- }
+ _gdk_quartz_window_update_position (list->data);
g_list_free (windows);
}
#define WINDOW_IS_TOPLEVEL(window) \
(GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
- GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \
- GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
+ GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
/*
* GdkQuartzWindow
{
GdkWindow *toplevel;
- toplevel = gdk_window_get_effective_toplevel (window);
+ toplevel = gdk_window_get_toplevel (window);
if (toplevel && WINDOW_IS_TOPLEVEL (toplevel))
{
GdkWindowImplQuartz *toplevel_impl;
rect->width = 1;
rect->height = 1;
- toplevel = gdk_window_get_effective_toplevel (window);
+ toplevel = gdk_window_get_toplevel (window);
impl = GDK_WINDOW_IMPL_QUARTZ (toplevel->impl);
ns_rect = [impl->toplevel frame];
native = gdk_window_get_toplevel (window);
- while (native->window_type == GDK_WINDOW_OFFSCREEN)
- {
- native = gdk_offscreen_window_get_embedder (native);
-
- if (native == NULL ||
- (!_gdk_window_has_impl (native) &&
- !gdk_window_is_viewable (native)))
- return GDK_GRAB_NOT_VIEWABLE;
-
- native = gdk_window_get_toplevel (native);
- }
-
if (native == NULL || GDK_WINDOW_DESTROYED (native))
return GDK_GRAB_NOT_VIEWABLE;
static guint signals[LAST_SIGNAL];
#define WINDOW_IS_TOPLEVEL_OR_FOREIGN(window) \
- (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
- GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
+ (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD)
#define WINDOW_IS_TOPLEVEL(window) \
(GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
- GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \
- GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
+ GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
#define MAX_WL_BUFFER_SIZE (4083) /* 4096 minus header, string argument length and NUL byte */
while (parent &&
!gdk_window_has_native (parent) &&
- gdk_window_get_effective_parent (parent))
+ gdk_window_get_parent (parent))
{
*x += parent->x;
*y += parent->y;
- parent = gdk_window_get_effective_parent (parent);
+ parent = gdk_window_get_parent (parent);
}
return parent;
}
if (transient_for)
- transient_for = get_popup_parent (gdk_window_get_effective_toplevel (transient_for));
+ transient_for = get_popup_parent (gdk_window_get_toplevel (transient_for));
/* If the position was not explicitly set, start the popup at the
* position of the device that holds the grab.
}
else
{
- transient_for = gdk_window_get_effective_toplevel (impl->transient_for);
+ transient_for = gdk_window_get_toplevel (impl->transient_for);
transient_for = get_popup_parent (transient_for);
}
g_return_if_fail (window != NULL);
- if (gdk_window_get_window_type (window) == GDK_WINDOW_OFFSCREEN)
- return;
-
if (g_object_get_data (G_OBJECT (window), "gdk-dnd-registered") != NULL)
return;
else
#define WINDOW_IS_TOPLEVEL(window) \
(GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
- GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \
- GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
+ GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
GdkScreen *
GDK_WINDOW_SCREEN (GObject *win)
guint have_input_shapes : 1;
gint shape_event_base;
- /* The offscreen window that has the pointer in it (if any) */
- GdkWindow *active_offscreen_window;
-
GSList *error_traps;
gint wm_moveresize_button;
g_return_if_fail (window != NULL);
- if (gdk_window_get_window_type (window) == GDK_WINDOW_OFFSCREEN)
- return;
-
base_precache_atoms (display);
if (g_object_get_data (G_OBJECT (window), "gdk-dnd-registered") != NULL)
GdkToplevelX11 *toplevel;
GdkWindowHints geom_mask;
- if (window->window_type == GDK_WINDOW_OFFSCREEN)
- return;
-
impl = GDK_WINDOW_IMPL_X11 (window->impl);
impl->window_scale = scale;
gtkmountoperation.h \
gtknativedialog.h \
gtknotebook.h \
- gtkoffscreenwindow.h \
gtkorientable.h \
gtkoverlay.h \
gtkpadcontroller.h \
gtkmountoperation.c \
gtknativedialog.c \
gtknotebook.c \
- gtkoffscreenwindow.c \
gtkorientable.c \
gtkoverlay.c \
gtkpadcontroller.c \
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkMessageDialog, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkMountOperation, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkNotebook, g_object_unref)
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkOffscreenWindow, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkOrientable, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkOverlay, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkPageSetup, g_object_unref)
#include <gtk/gtkmountoperation.h>
#include <gtk/gtknativedialog.h>
#include <gtk/gtknotebook.h>
-#include <gtk/gtkoffscreenwindow.h>
#include <gtk/gtkorientable.h>
#include <gtk/gtkoverlay.h>
#include <gtk/gtkpadcontroller.h>
* nswindow. Then, we convert to the NSWindow coordinate system.
*/
window = event->any.window;
- GdkWindow *toplevel = gdk_window_get_effective_toplevel (window);
+ GdkWindow *toplevel = gdk_window_get_toplevel (window);
while (window != toplevel)
{
gdk_window_coords_to_parent (window, old_x, old_y,
&dx, &dy);
- window = gdk_window_get_effective_parent (window);
+ window = gdk_window_get_parent (window);
}
}
time = (double)gdk_event_get_time (event);
&parent_x, &parent_y);
relative_x = parent_x;
relative_y = parent_y;
- event_window = gdk_window_get_effective_parent (event_window);
+ event_window = gdk_window_get_parent (event_window);
}
child = gtk_flow_box_find_child_at_pos (box, relative_x, relative_y);
gtk_widget_get_window (widget) == window)
return window;
- window = gdk_window_get_effective_parent (window);
+ window = gdk_window_get_parent (window);
}
return NULL;
gdk_window_get_position (window, &wx, &wy);
event_x += wx;
event_y += wy;
- window = gdk_window_get_effective_parent (window);
+ window = gdk_window_get_parent (window);
}
if (!window)
if (window == parent)
return TRUE;
- window = gdk_window_get_effective_parent (window);
+ window = gdk_window_get_parent (window);
}
return FALSE;
{
gdk_window_coords_to_parent (event_window, 0, relative_y, NULL, &parent_y);
relative_y = parent_y;
- event_window = gdk_window_get_effective_parent (event_window);
+ event_window = gdk_window_get_parent (event_window);
}
row = gtk_list_box_get_row_at_y (box, relative_y);
+++ /dev/null
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors: Cody Russell <crussell@canonical.com>
- * Alexander Larsson <alexl@redhat.com>
- */
-
-#include "config.h"
-
-#include "gtkoffscreenwindow.h"
-#include "gtkwidgetprivate.h"
-#include "gtkcontainerprivate.h"
-#include "gtkprivate.h"
-
-/**
- * SECTION:gtkoffscreenwindow
- * @short_description: A toplevel to manage offscreen rendering of child widgets
- * @title: GtkOffscreenWindow
- *
- * GtkOffscreenWindow is strictly intended to be used for obtaining
- * snapshots of widgets that are not part of a normal widget hierarchy.
- * Since #GtkOffscreenWindow is a toplevel widget you cannot obtain
- * snapshots of a full window with it since you cannot pack a toplevel
- * widget in another toplevel.
- *
- * The idea is to take a widget and manually set the state of it,
- * add it to a GtkOffscreenWindow and then retrieve the snapshot
- * as a #cairo_surface_t or #GdkPixbuf.
- *
- * GtkOffscreenWindow derives from #GtkWindow only as an implementation
- * detail. Applications should not use any API specific to #GtkWindow
- * to operate on this object. It should be treated as a #GtkBin that
- * has no parent widget.
- *
- * When contained offscreen widgets are redrawn, GtkOffscreenWindow
- * will emit a #GtkWidget::damage-event signal.
- */
-
-G_DEFINE_TYPE (GtkOffscreenWindow, gtk_offscreen_window, GTK_TYPE_WINDOW);
-
-static void
-gtk_offscreen_window_measure (GtkWidget *widget,
- GtkOrientation orientation,
- int for_size,
- int *minimum,
- int *natural,
- int *minimum_baseline,
- int *natural_baseline)
-{
- GtkBin *bin = GTK_BIN (widget);
- GtkWidget *child = gtk_bin_get_child (bin);
- int default_size;
-
- *minimum = 0;
- *natural = 0;
-
- if (child != NULL && gtk_widget_get_visible (child))
- {
- int child_min, child_nat;
-
- gtk_widget_measure (child, orientation, for_size, &child_min, &child_nat, NULL, NULL);
- *minimum += child_min;
- *natural += child_nat;
- }
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_window_get_default_size (GTK_WINDOW (widget), &default_size, NULL);
- else
- gtk_window_get_default_size (GTK_WINDOW (widget), NULL, &default_size);
-
- *minimum = MAX (*minimum, default_size);
- *natural = MAX (*natural, default_size);
-}
-
-static void
-gtk_offscreen_window_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GtkBin *bin = GTK_BIN (widget);
- GtkWidget *child;
-
- gtk_widget_set_allocation (widget, allocation);
-
- if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (gtk_widget_get_window (widget),
- allocation->x,
- allocation->y,
- allocation->width,
- allocation->height);
-
- child = gtk_bin_get_child (bin);
-
- if (child != NULL && gtk_widget_get_visible (child))
- {
- GtkAllocation child_alloc;
-
- child_alloc.x = 0;
- child_alloc.y = 0;
- child_alloc.width = allocation->width;
- child_alloc.height = allocation->height;
-
- gtk_widget_size_allocate (child, &child_alloc);
- }
-
- gtk_widget_queue_draw (widget);
-}
-
-static void
-gtk_offscreen_window_realize (GtkWidget *widget)
-{
- GtkAllocation allocation;
- GtkBin *bin;
- GtkWidget *child;
- GdkWindow *window;
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- bin = GTK_BIN (widget);
-
- gtk_widget_set_realized (widget, TRUE);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- attributes.x = allocation.x;
- attributes.y = allocation.y;
- attributes.width = allocation.width;
- attributes.height = allocation.height;
- attributes.window_type = GDK_WINDOW_OFFSCREEN;
- attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
- attributes.wclass = GDK_INPUT_OUTPUT;
-
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gtk_widget_set_window (widget, window);
- gtk_widget_register_window (widget, window);
-
- child = gtk_bin_get_child (bin);
- if (child)
- gtk_widget_set_parent_window (child, window);
-}
-
-static void
-gtk_offscreen_window_resize (GtkWidget *widget)
-{
- GtkAllocation allocation = { 0, 0 };
- GtkRequisition requisition;
-
- gtk_widget_get_preferred_size (widget, &requisition, NULL);
-
- allocation.width = requisition.width;
- allocation.height = requisition.height;
- gtk_widget_size_allocate (widget, &allocation);
-}
-
-static void
-move_focus (GtkWidget *widget,
- GtkDirectionType dir)
-{
- gtk_widget_child_focus (widget, dir);
-
- if (!gtk_container_get_focus_child (GTK_CONTAINER (widget)))
- gtk_window_set_focus (GTK_WINDOW (widget), NULL);
-}
-
-static void
-gtk_offscreen_window_show (GtkWidget *widget)
-{
- gboolean need_resize;
-
- _gtk_widget_set_visible_flag (widget, TRUE);
-
- need_resize = _gtk_widget_get_alloc_needed (widget) || !gtk_widget_get_realized (widget);
-
- if (need_resize)
- gtk_offscreen_window_resize (widget);
-
- gtk_widget_map (widget);
-
- /* Try to make sure that we have some focused widget */
- if (!gtk_window_get_focus (GTK_WINDOW (widget)))
- move_focus (widget, GTK_DIR_TAB_FORWARD);
-}
-
-static void
-gtk_offscreen_window_hide (GtkWidget *widget)
-{
- _gtk_widget_set_visible_flag (widget, FALSE);
- gtk_widget_unmap (widget);
-}
-
-static void
-gtk_offscreen_window_check_resize (GtkContainer *container)
-{
- GtkWidget *widget = GTK_WIDGET (container);
-
- if (gtk_widget_get_visible (widget))
- gtk_offscreen_window_resize (widget);
-}
-
-static void
-gtk_offscreen_window_class_init (GtkOffscreenWindowClass *class)
-{
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- widget_class = GTK_WIDGET_CLASS (class);
- container_class = GTK_CONTAINER_CLASS (class);
-
- widget_class->realize = gtk_offscreen_window_realize;
- widget_class->show = gtk_offscreen_window_show;
- widget_class->hide = gtk_offscreen_window_hide;
- widget_class->measure = gtk_offscreen_window_measure;
- widget_class->size_allocate = gtk_offscreen_window_size_allocate;
-
- container_class->check_resize = gtk_offscreen_window_check_resize;
-}
-
-static void
-gtk_offscreen_window_init (GtkOffscreenWindow *window)
-{
-}
-
-/* --- functions --- */
-/**
- * gtk_offscreen_window_new:
- *
- * Creates a toplevel container widget that is used to retrieve
- * snapshots of widgets without showing them on the screen.
- *
- * Returns: A pointer to a #GtkWidget
- *
- * Since: 2.20
- */
-GtkWidget *
-gtk_offscreen_window_new (void)
-{
- return g_object_new (gtk_offscreen_window_get_type (), NULL);
-}
-
-/**
- * gtk_offscreen_window_get_surface:
- * @offscreen: the #GtkOffscreenWindow contained widget.
- *
- * Retrieves a snapshot of the contained widget in the form of
- * a #cairo_surface_t. If you need to keep this around over window
- * resizes then you should add a reference to it.
- *
- * Returns: (nullable) (transfer none): A #cairo_surface_t pointer to the offscreen
- * surface, or %NULL.
- *
- * Since: 2.20
- */
-cairo_surface_t *
-gtk_offscreen_window_get_surface (GtkOffscreenWindow *offscreen)
-{
- g_return_val_if_fail (GTK_IS_OFFSCREEN_WINDOW (offscreen), NULL);
-
- return gdk_offscreen_window_get_surface (gtk_widget_get_window (GTK_WIDGET (offscreen)));
-}
-
-/**
- * gtk_offscreen_window_get_pixbuf:
- * @offscreen: the #GtkOffscreenWindow contained widget.
- *
- * Retrieves a snapshot of the contained widget in the form of
- * a #GdkPixbuf. This is a new pixbuf with a reference count of 1,
- * and the application should unreference it once it is no longer
- * needed.
- *
- * Returns: (nullable) (transfer full): A #GdkPixbuf pointer, or %NULL.
- *
- * Since: 2.20
- */
-GdkPixbuf *
-gtk_offscreen_window_get_pixbuf (GtkOffscreenWindow *offscreen)
-{
- cairo_surface_t *surface;
- GdkPixbuf *pixbuf = NULL;
- GdkWindow *window;
-
- g_return_val_if_fail (GTK_IS_OFFSCREEN_WINDOW (offscreen), NULL);
-
- window = gtk_widget_get_window (GTK_WIDGET (offscreen));
- surface = gdk_offscreen_window_get_surface (window);
-
- if (surface != NULL)
- {
- pixbuf = gdk_pixbuf_get_from_surface (surface,
- 0, 0,
- gdk_window_get_width (window),
- gdk_window_get_height (window));
- }
-
- return pixbuf;
-}
+++ /dev/null
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors: Cody Russell <crussell@canonical.com>
- * Alexander Larsson <alexl@redhat.com>
- */
-
-#ifndef __GTK_OFFSCREEN_WINDOW_H__
-#define __GTK_OFFSCREEN_WINDOW_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkwindow.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_OFFSCREEN_WINDOW (gtk_offscreen_window_get_type ())
-#define GTK_OFFSCREEN_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_OFFSCREEN_WINDOW, GtkOffscreenWindow))
-#define GTK_OFFSCREEN_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_OFFSCREEN_WINDOW, GtkOffscreenWindowClass))
-#define GTK_IS_OFFSCREEN_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_OFFSCREEN_WINDOW))
-#define GTK_IS_OFFSCREEN_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_OFFSCREEN_WINDOW))
-#define GTK_OFFSCREEN_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_OFFSCREEN_WINDOW, GtkOffscreenWindowClass))
-
-typedef struct _GtkOffscreenWindow GtkOffscreenWindow;
-typedef struct _GtkOffscreenWindowClass GtkOffscreenWindowClass;
-
-struct _GtkOffscreenWindow
-{
- GtkWindow parent_object;
-};
-
-/**
- * GtkOffscreenWindowClass:
- * @parent_class: The parent class.
- */
-struct _GtkOffscreenWindowClass
-{
- GtkWindowClass parent_class;
-
- /*< private >*/
-
- /* Padding for future expansion */
- void (*_gtk_reserved1) (void);
- void (*_gtk_reserved2) (void);
- void (*_gtk_reserved3) (void);
- void (*_gtk_reserved4) (void);
-};
-
-GDK_AVAILABLE_IN_ALL
-GType gtk_offscreen_window_get_type (void) G_GNUC_CONST;
-
-GDK_AVAILABLE_IN_ALL
-GtkWidget *gtk_offscreen_window_new (void);
-GDK_AVAILABLE_IN_ALL
-cairo_surface_t *gtk_offscreen_window_get_surface (GtkOffscreenWindow *offscreen);
-GDK_AVAILABLE_IN_ALL
-GdkPixbuf *gtk_offscreen_window_get_pixbuf (GtkOffscreenWindow *offscreen);
-
-G_END_DECLS
-
-#endif /* __GTK_OFFSCREEN_WINDOW_H__ */
gdk_window_get_position (window, &wx, &wy);
event_x += wx;
event_y += wy;
- window = gdk_window_get_effective_parent (window);
+ window = gdk_window_get_parent (window);
}
if (!gtk_widget_get_has_window (event_widget))
child_loc.x = px;
child_loc.y = py;
- window = gdk_window_get_effective_parent (window);
+ window = gdk_window_get_parent (window);
}
/* Failing to find widget->window can happen for e.g. a detached handle box;
src_x = dx;
src_y = dy;
- window = gdk_window_get_effective_parent (window);
+ window = gdk_window_get_parent (window);
if (!window) /* Handle GtkHandleBox */
return FALSE;
{
dest_list = g_list_prepend (dest_list, window);
- window = gdk_window_get_effective_parent (window);
+ window = gdk_window_get_parent (window);
if (!window) /* Handle GtkHandleBox */
{
while (from_ancestor != NULL)
{
- from_ancestor = gdk_window_get_effective_parent (from_ancestor);
+ from_ancestor = gdk_window_get_parent (from_ancestor);
if (from_ancestor == NULL)
break;
from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
while (to_ancestor != NULL)
{
- to_ancestor = gdk_window_get_effective_parent (to_ancestor);
+ to_ancestor = gdk_window_get_parent (to_ancestor);
if (to_ancestor == NULL)
break;
to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
{
if (from_ancestor != NULL)
{
- from_ancestor = gdk_window_get_effective_parent (from_ancestor);
+ from_ancestor = gdk_window_get_parent (from_ancestor);
if (from_ancestor == to_window)
break;
if (from_ancestor)
}
if (to_ancestor != NULL)
{
- to_ancestor = gdk_window_get_effective_parent (to_ancestor);
+ to_ancestor = gdk_window_get_parent (to_ancestor);
if (to_ancestor == from_window)
break;
if (to_ancestor)
gdk_window_show (gdk_window);
if (!disable_startup_notification &&
- !GTK_IS_OFFSCREEN_WINDOW (window) &&
priv->type != GTK_WINDOW_POPUP)
{
/* Do we have a custom startup-notification id? */
gtkmountoperation.obj \
gtkmountoperation-stub.obj \
gtknotebook.obj \
- gtkoffscreenwindow.obj \
gtkorientable.obj \
gtkpagesetup.obj \
gtkpaned.obj \
gtkmodules.h \
gtkmountoperation.h \
gtknotebook.h \
- gtkoffscreenwindow.h \
gtkorientable.h \
gtkpagesetup.h \
gtkpaned.h \
testmultidisplay \
testnotebookdnd \
testnouiprint \
- testoffscreen \
- testoffscreenwindow \
testorientable \
testoverlay \
testoverlaystyleclass \
testmultidisplay_DEPENDENCIES = $(TEST_DEPS)
testnotebookdnd_DEPENDENCIES = $(TEST_DEPS)
testnouiprint_DEPENDENCIES = $(TEST_DEPS)
-testoffscreen_DEPENDENCIES = $(TEST_DEPS)
-testoffscreenwindow_DEPENDENCIES = $(TEST_DEPS)
testappchooser_DEPENDENCIES = $(TEST_DEPS)
testappchooserbutton_DEPENDENCIES = $(TEST_DEPS)
testorientable_DEPENDENCIES = $(TEST_DEPS)
testtreemenu_SOURCES = \
testtreemenu.c
-testoffscreen_SOURCES = \
- gtkoffscreenbox.c \
- gtkoffscreenbox.h \
- testoffscreen.c
-
-testoffscreenwindow_SOURCES = \
- testoffscreenwindow.c
-
testoverlay_SOURCES = \
testoverlay.c
+++ /dev/null
-/*
- * gtkoffscreenbox.c
- */
-
-#include "config.h"
-
-#include <math.h>
-#include <gtk/gtk.h>
-
-#include "gtkoffscreenbox.h"
-
-static void gtk_offscreen_box_realize (GtkWidget *widget);
-static void gtk_offscreen_box_unrealize (GtkWidget *widget);
-static void gtk_offscreen_box_measure (GtkWidget *widget,
- GtkOrientation orientation,
- int for_size,
- int *minimum,
- int *natural,
- int *minimum_baseline,
- int *natural_baseline);
-static void gtk_offscreen_box_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gboolean gtk_offscreen_box_damage (GtkWidget *widget,
- GdkEventExpose *event);
-static gboolean gtk_offscreen_box_draw (GtkWidget *widget,
- cairo_t *cr);
-
-static void gtk_offscreen_box_add (GtkContainer *container,
- GtkWidget *child);
-static void gtk_offscreen_box_remove (GtkContainer *container,
- GtkWidget *widget);
-static void gtk_offscreen_box_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static GType gtk_offscreen_box_child_type (GtkContainer *container);
-
-#define CHILD1_SIZE_SCALE 1.0
-#define CHILD2_SIZE_SCALE 1.0
-
-G_DEFINE_TYPE (GtkOffscreenBox, gtk_offscreen_box, GTK_TYPE_CONTAINER);
-
-static void
-to_child_2 (GtkOffscreenBox *offscreen_box,
- double widget_x, double widget_y,
- double *x_out, double *y_out)
-{
- GtkAllocation child_area;
- double x, y, xr, yr;
- double cos_angle, sin_angle;
-
- x = widget_x;
- y = widget_y;
-
- if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
- {
- gtk_widget_get_allocation (offscreen_box->child1, &child_area);
- y -= child_area.height;
- }
-
- gtk_widget_get_allocation (offscreen_box->child2, &child_area);
-
- x -= child_area.width / 2;
- y -= child_area.height / 2;
-
- cos_angle = cos (-offscreen_box->angle);
- sin_angle = sin (-offscreen_box->angle);
-
- xr = x * cos_angle - y * sin_angle;
- yr = x * sin_angle + y * cos_angle;
- x = xr;
- y = yr;
-
- x += child_area.width / 2;
- y += child_area.height / 2;
-
- *x_out = x;
- *y_out = y;
-}
-
-static void
-to_parent_2 (GtkOffscreenBox *offscreen_box,
- double offscreen_x, double offscreen_y,
- double *x_out, double *y_out)
-{
- GtkAllocation child_area;
- double x, y, xr, yr;
- double cos_angle, sin_angle;
-
- gtk_widget_get_allocation (offscreen_box->child2, &child_area);
-
- x = offscreen_x;
- y = offscreen_y;
-
- x -= child_area.width / 2;
- y -= child_area.height / 2;
-
- cos_angle = cos (offscreen_box->angle);
- sin_angle = sin (offscreen_box->angle);
-
- xr = x * cos_angle - y * sin_angle;
- yr = x * sin_angle + y * cos_angle;
- x = xr;
- y = yr;
-
- x += child_area.width / 2;
- y += child_area.height / 2;
-
- if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
- {
- gtk_widget_get_allocation (offscreen_box->child1, &child_area);
- y += child_area.height;
- }
-
- *x_out = x;
- *y_out = y;
-}
-
-static void
-gtk_offscreen_box_class_init (GtkOffscreenBoxClass *klass)
-{
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
-
- widget_class->realize = gtk_offscreen_box_realize;
- widget_class->unrealize = gtk_offscreen_box_unrealize;
- widget_class->measure = gtk_offscreen_box_measure;
- widget_class->size_allocate = gtk_offscreen_box_size_allocate;
- widget_class->draw = gtk_offscreen_box_draw;
-
- g_signal_override_class_closure (g_signal_lookup ("damage-event", GTK_TYPE_WIDGET),
- GTK_TYPE_OFFSCREEN_BOX,
- g_cclosure_new (G_CALLBACK (gtk_offscreen_box_damage),
- NULL, NULL));
-
- container_class->add = gtk_offscreen_box_add;
- container_class->remove = gtk_offscreen_box_remove;
- container_class->forall = gtk_offscreen_box_forall;
- container_class->child_type = gtk_offscreen_box_child_type;
-}
-
-static void
-gtk_offscreen_box_init (GtkOffscreenBox *offscreen_box)
-{
- gtk_widget_set_has_window (GTK_WIDGET (offscreen_box), TRUE);
-}
-
-GtkWidget *
-gtk_offscreen_box_new (void)
-{
- return g_object_new (GTK_TYPE_OFFSCREEN_BOX, NULL);
-}
-
-static GdkWindow *
-pick_offscreen_child (GdkWindow *offscreen_window,
- double widget_x, double widget_y,
- GtkOffscreenBox *offscreen_box)
-{
- GtkAllocation child_area;
- double x, y;
-
- /* First check for child 2 */
- if (offscreen_box->child2 &&
- gtk_widget_get_visible (offscreen_box->child2))
- {
- to_child_2 (offscreen_box,
- widget_x, widget_y,
- &x, &y);
-
- gtk_widget_get_allocation (offscreen_box->child2, &child_area);
-
- if (x >= 0 && x < child_area.width &&
- y >= 0 && y < child_area.height)
- return offscreen_box->offscreen_window2;
- }
-
- if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
- {
- x = widget_x;
- y = widget_y;
-
- gtk_widget_get_allocation (offscreen_box->child1, &child_area);
-
- if (x >= 0 && x < child_area.width &&
- y >= 0 && y < child_area.height)
- return offscreen_box->offscreen_window1;
- }
-
- return NULL;
-}
-
-static void
-offscreen_window_to_parent1 (GdkWindow *offscreen_window,
- double offscreen_x,
- double offscreen_y,
- double *parent_x,
- double *parent_y,
- GtkOffscreenBox *offscreen_box)
-{
- *parent_x = offscreen_x;
- *parent_y = offscreen_y;
-}
-
-static void
-offscreen_window_from_parent1 (GdkWindow *window,
- double parent_x,
- double parent_y,
- double *offscreen_x,
- double *offscreen_y,
- GtkOffscreenBox *offscreen_box)
-{
- *offscreen_x = parent_x;
- *offscreen_y = parent_y;
-}
-
-static void
-offscreen_window_to_parent2 (GdkWindow *offscreen_window,
- double offscreen_x,
- double offscreen_y,
- double *parent_x,
- double *parent_y,
- GtkOffscreenBox *offscreen_box)
-{
- to_parent_2 (offscreen_box,
- offscreen_x, offscreen_y,
- parent_x, parent_y);
-}
-
-static void
-offscreen_window_from_parent2 (GdkWindow *window,
- double parent_x,
- double parent_y,
- double *offscreen_x,
- double *offscreen_y,
- GtkOffscreenBox *offscreen_box)
-{
- to_child_2 (offscreen_box,
- parent_x, parent_y,
- offscreen_x, offscreen_y);
-}
-
-static cairo_surface_t *
-gdk_offscreen_box_create_alpha_image_surface (GdkWindow *offscreen,
- gint width,
- gint height)
-{
- return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
-}
-
-static void
-gtk_offscreen_box_realize (GtkWidget *widget)
-{
- GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget);
- GtkAllocation allocation, child_area;
- GdkWindow *window;
- GdkWindowAttr attributes;
- gint attributes_mask;
- GtkRequisition child_requisition;
- int start_y = 0;
-
- gtk_widget_set_realized (widget, TRUE);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- window = gdk_window_new_child (gtk_widget_get_parent_window (widget),
- gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_POINTER_MOTION_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_SCROLL_MASK
- | GDK_ENTER_NOTIFY_MASK
- | GDK_LEAVE_NOTIFY_MASK,
- &allocation);
- gtk_widget_set_window (widget, window);
- gdk_window_set_user_data (window, widget);
-
- g_signal_connect (window, "pick-embedded-child",
- G_CALLBACK (pick_offscreen_child), offscreen_box);
-
- attributes.window_type = GDK_WINDOW_OFFSCREEN;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.event_mask = gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_POINTER_MOTION_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_SCROLL_MASK
- | GDK_ENTER_NOTIFY_MASK
- | GDK_LEAVE_NOTIFY_MASK;
-
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- /* Child 1 */
- attributes.x = attributes.y = 0;
- attributes.width = allocation.width;
- attributes.height = allocation.height;
- if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
- {
- gtk_widget_get_allocation (offscreen_box->child1, &child_area);
-
- attributes.width = child_area.width;
- attributes.height = child_area.height;
- start_y += child_area.height;
- }
- offscreen_box->offscreen_window1 = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)),
- &attributes, attributes_mask);
- gdk_window_set_user_data (offscreen_box->offscreen_window1, widget);
- if (offscreen_box->child1)
- gtk_widget_set_parent_window (offscreen_box->child1, offscreen_box->offscreen_window1);
-
- gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window1,
- window);
-
- g_signal_connect (offscreen_box->offscreen_window1, "to-embedder",
- G_CALLBACK (offscreen_window_to_parent1), offscreen_box);
- g_signal_connect (offscreen_box->offscreen_window1, "from-embedder",
- G_CALLBACK (offscreen_window_from_parent1), offscreen_box);
-
- /* Child 2 */
- attributes.y = start_y;
- child_requisition.width = child_requisition.height = 0;
- if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2))
- {
- gtk_widget_get_allocation (offscreen_box->child2, &child_area);
-
- attributes.width = child_area.width;
- attributes.height = child_area.height;
- }
- offscreen_box->offscreen_window2 = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)),
- &attributes, attributes_mask);
- gdk_window_set_user_data (offscreen_box->offscreen_window2, widget);
- if (offscreen_box->child2)
- gtk_widget_set_parent_window (offscreen_box->child2, offscreen_box->offscreen_window2);
- gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window2,
- window);
-
- g_signal_connect (offscreen_box->offscreen_window2, "create-surface",
- G_CALLBACK (gdk_offscreen_box_create_alpha_image_surface),
- offscreen_box);
- g_signal_connect (offscreen_box->offscreen_window2, "to-embedder",
- G_CALLBACK (offscreen_window_to_parent2), offscreen_box);
- g_signal_connect (offscreen_box->offscreen_window2, "from-embedder",
- G_CALLBACK (offscreen_window_from_parent2), offscreen_box);
-
- gdk_window_show (offscreen_box->offscreen_window1);
- gdk_window_show (offscreen_box->offscreen_window2);
-}
-
-static void
-gtk_offscreen_box_unrealize (GtkWidget *widget)
-{
- GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget);
-
- gdk_window_set_user_data (offscreen_box->offscreen_window1, NULL);
- gdk_window_destroy (offscreen_box->offscreen_window1);
- offscreen_box->offscreen_window1 = NULL;
-
- gdk_window_set_user_data (offscreen_box->offscreen_window2, NULL);
- gdk_window_destroy (offscreen_box->offscreen_window2);
- offscreen_box->offscreen_window2 = NULL;
-
- GTK_WIDGET_CLASS (gtk_offscreen_box_parent_class)->unrealize (widget);
-}
-
-static GType
-gtk_offscreen_box_child_type (GtkContainer *container)
-{
- GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (container);
-
- if (offscreen_box->child1 && offscreen_box->child2)
- return G_TYPE_NONE;
-
- return GTK_TYPE_WIDGET;
-}
-
-static void
-gtk_offscreen_box_add (GtkContainer *container,
- GtkWidget *widget)
-{
- GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (container);
-
- if (!offscreen_box->child1)
- gtk_offscreen_box_add1 (offscreen_box, widget);
- else if (!offscreen_box->child2)
- gtk_offscreen_box_add2 (offscreen_box, widget);
- else
- g_warning ("GtkOffscreenBox cannot have more than 2 children");
-}
-
-void
-gtk_offscreen_box_add1 (GtkOffscreenBox *offscreen_box,
- GtkWidget *child)
-{
- g_return_if_fail (GTK_IS_OFFSCREEN_BOX (offscreen_box));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- if (offscreen_box->child1 == NULL)
- {
- gtk_widget_set_parent_window (child, offscreen_box->offscreen_window1);
- gtk_widget_set_parent (child, GTK_WIDGET (offscreen_box));
- offscreen_box->child1 = child;
- }
-}
-
-void
-gtk_offscreen_box_add2 (GtkOffscreenBox *offscreen_box,
- GtkWidget *child)
-{
- g_return_if_fail (GTK_IS_OFFSCREEN_BOX (offscreen_box));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- if (offscreen_box->child2 == NULL)
- {
- gtk_widget_set_parent_window (child, offscreen_box->offscreen_window2);
- gtk_widget_set_parent (child, GTK_WIDGET (offscreen_box));
- offscreen_box->child2 = child;
- }
-}
-
-static void
-gtk_offscreen_box_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (container);
- gboolean was_visible;
-
- was_visible = gtk_widget_get_visible (widget);
-
- if (offscreen_box->child1 == widget)
- {
- gtk_widget_unparent (widget);
-
- offscreen_box->child1 = NULL;
-
- if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container)))
- gtk_widget_queue_resize (GTK_WIDGET (container));
- }
- else if (offscreen_box->child2 == widget)
- {
- gtk_widget_unparent (widget);
-
- offscreen_box->child2 = NULL;
-
- if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container)))
- gtk_widget_queue_resize (GTK_WIDGET (container));
- }
-}
-
-static void
-gtk_offscreen_box_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (container);
-
- g_return_if_fail (callback != NULL);
-
- if (offscreen_box->child1)
- (*callback) (offscreen_box->child1, callback_data);
- if (offscreen_box->child2)
- (*callback) (offscreen_box->child2, callback_data);
-}
-
-void
-gtk_offscreen_box_set_angle (GtkOffscreenBox *offscreen_box,
- gdouble angle)
-{
- g_return_if_fail (GTK_IS_OFFSCREEN_BOX (offscreen_box));
-
- offscreen_box->angle = angle;
- gtk_widget_queue_draw (GTK_WIDGET (offscreen_box));
-
- /* TODO: Really needs to resent pointer events if over the rotated window */
-}
-
-
-static void
-gtk_offscreen_box_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget);
- int w, h;
-
- w = 0;
- h = 0;
-
- if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
- {
- GtkRequisition child_requisition;
-
- gtk_widget_get_preferred_size ( (offscreen_box->child1),
- &child_requisition, NULL);
-
- w = MAX (w, CHILD1_SIZE_SCALE * child_requisition.width);
- h += CHILD1_SIZE_SCALE * child_requisition.height;
- }
-
- if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2))
- {
- GtkRequisition child_requisition;
-
- gtk_widget_get_preferred_size ( (offscreen_box->child2),
- &child_requisition, NULL);
-
- w = MAX (w, CHILD2_SIZE_SCALE * child_requisition.width);
- h += CHILD2_SIZE_SCALE * child_requisition.height;
- }
-
- requisition->width = w;
- requisition->height = h;
-}
-
-
-static void
-gtk_offscreen_box_measure (GtkWidget *widget,
- GtkOrientation orientation,
- int for_size,
- int *minimum,
- int *natural,
- int *minimum_baseline,
- int *natural_baseline)
-{
- GtkRequisition requisition;
-
- gtk_offscreen_box_size_request (widget, &requisition);
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- *minimum = *natural = requisition.width;
- else
- *minimum = *natural = requisition.height;
-}
-
-static void
-gtk_offscreen_box_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GtkOffscreenBox *offscreen_box;
- gint start_y;
-
- offscreen_box = GTK_OFFSCREEN_BOX (widget);
-
- gtk_widget_set_allocation (widget, allocation);
-
- if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (gtk_widget_get_window (widget),
- allocation->x,
- allocation->y,
- allocation->width,
- allocation->height);
-
- start_y = 0;
-
- if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
- {
- GtkRequisition child_requisition;
- GtkAllocation child_allocation;
-
- gtk_widget_get_preferred_size (offscreen_box->child1,
- &child_requisition, NULL);
- child_allocation.x = child_requisition.width * (CHILD1_SIZE_SCALE - 1.0) / 2;
- child_allocation.y = start_y + child_requisition.height * (CHILD1_SIZE_SCALE - 1.0) / 2;
- child_allocation.width = allocation->width;
- child_allocation.height = child_requisition.height;
-
- start_y += CHILD1_SIZE_SCALE * child_requisition.height;
-
- if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (offscreen_box->offscreen_window1,
- child_allocation.x,
- child_allocation.y,
- child_allocation.width,
- child_allocation.height);
-
- child_allocation.x = child_allocation.y = 0;
- gtk_widget_size_allocate (offscreen_box->child1, &child_allocation);
- }
-
- if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2))
- {
- GtkRequisition child_requisition;
- GtkAllocation child_allocation;
-
- gtk_widget_get_preferred_size (offscreen_box->child2,
- &child_requisition, NULL);
- child_allocation.x = child_requisition.width * (CHILD2_SIZE_SCALE - 1.0) / 2;
- child_allocation.y = start_y + child_requisition.height * (CHILD2_SIZE_SCALE - 1.0) / 2;
- child_allocation.width = allocation->width;
- child_allocation.height = child_requisition.height;
-
- start_y += CHILD2_SIZE_SCALE * child_requisition.height;
-
- if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (offscreen_box->offscreen_window2,
- child_allocation.x,
- child_allocation.y,
- child_allocation.width,
- child_allocation.height);
-
- child_allocation.x = child_allocation.y = 0;
- gtk_widget_size_allocate (offscreen_box->child2, &child_allocation);
- }
-}
-
-static gboolean
-gtk_offscreen_box_damage (GtkWidget *widget,
- GdkEventExpose *event)
-{
- gdk_window_invalidate_rect (gtk_widget_get_window (widget),
- NULL, FALSE);
-
- return TRUE;
-}
-
-static gboolean
-gtk_offscreen_box_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget);
- GdkWindow *window;
-
- window = gtk_widget_get_window (widget);
- if (gtk_cairo_should_draw_window (cr, window))
- {
- cairo_surface_t *surface;
- GtkAllocation child_area;
-
- if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
- {
- surface = gdk_offscreen_window_get_surface (offscreen_box->offscreen_window1);
-
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_paint (cr);
-
- gtk_widget_get_allocation (offscreen_box->child1, &child_area);
- cairo_translate (cr, 0, child_area.height);
- }
-
- if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2))
- {
- surface = gdk_offscreen_window_get_surface (offscreen_box->offscreen_window2);
-
- gtk_widget_get_allocation (offscreen_box->child2, &child_area);
-
- /* transform */
- cairo_translate (cr, child_area.width / 2, child_area.height / 2);
- cairo_rotate (cr, offscreen_box->angle);
- cairo_translate (cr, -child_area.width / 2, -child_area.height / 2);
-
- /* paint */
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_paint (cr);
- }
- }
- else if (gtk_cairo_should_draw_window (cr, offscreen_box->offscreen_window1))
- {
- gtk_render_background (gtk_widget_get_style_context (widget), cr,
- 0, 0,
-
- gdk_window_get_width (offscreen_box->offscreen_window1),
- gdk_window_get_height (offscreen_box->offscreen_window1));
-
- if (offscreen_box->child1)
- gtk_container_propagate_draw (GTK_CONTAINER (widget),
- offscreen_box->child1,
- cr);
- }
- else if (gtk_cairo_should_draw_window (cr, offscreen_box->offscreen_window2))
- {
- gtk_render_background (gtk_widget_get_style_context (widget), cr,
- 0, 0,
- gdk_window_get_width (offscreen_box->offscreen_window2),
- gdk_window_get_height (offscreen_box->offscreen_window2));
-
- if (offscreen_box->child2)
- gtk_container_propagate_draw (GTK_CONTAINER (widget),
- offscreen_box->child2,
- cr);
- }
-
- return FALSE;
-}
+++ /dev/null
-#ifndef __GTK_OFFSCREEN_BOX_H__
-#define __GTK_OFFSCREEN_BOX_H__
-
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_OFFSCREEN_BOX (gtk_offscreen_box_get_type ())
-#define GTK_OFFSCREEN_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_OFFSCREEN_BOX, GtkOffscreenBox))
-#define GTK_OFFSCREEN_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_OFFSCREEN_BOX, GtkOffscreenBoxClass))
-#define GTK_IS_OFFSCREEN_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_OFFSCREEN_BOX))
-#define GTK_IS_OFFSCREEN_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_OFFSCREEN_BOX))
-#define GTK_OFFSCREEN_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_OFFSCREEN_BOX, GtkOffscreenBoxClass))
-
-typedef struct _GtkOffscreenBox GtkOffscreenBox;
-typedef struct _GtkOffscreenBoxClass GtkOffscreenBoxClass;
-
-struct _GtkOffscreenBox
-{
- GtkContainer container;
-
- GtkWidget *child1;
- GtkWidget *child2;
-
- GdkWindow *offscreen_window1;
- GdkWindow *offscreen_window2;
-
- gdouble angle;
-};
-
-struct _GtkOffscreenBoxClass
-{
- GtkBinClass parent_class;
-};
-
-GType gtk_offscreen_box_get_type (void) G_GNUC_CONST;
-GtkWidget* gtk_offscreen_box_new (void);
-void gtk_offscreen_box_add1 (GtkOffscreenBox *offscreen,
- GtkWidget *child);
-void gtk_offscreen_box_add2 (GtkOffscreenBox *offscreen,
- GtkWidget *child);
-void gtk_offscreen_box_set_angle (GtkOffscreenBox *offscreen,
- double angle);
-
-
-
-G_END_DECLS
-
-#endif /* __GTK_OFFSCREEN_BOX_H__ */
testicontheme testiconview testimage testinput \
testmountoperation testmenubars testmerge testmultidisplay testmultiscreen \
testnouiprint testnotebookdnd \
- testoffscreen testorientable \
+ testorientable \
testprint \
testrecentchooser testrecentchoosermenu testrichtext \
testscale testselection testspinbutton \
EXTRA_LIBS = $(ATK_LIBS)
!ENDIF
-!IFDEF EXTRA_testoffscreen
-EXTRA_OBJETCS = gtkoffscreenbox.obj
-!ENDIF
-
!IFDEF EXTRA_testprint
EXTRA_OBJETCS = testprintfileoperation.obj
EXTRA_LIBS = $(PANGOCAIRO_LIBS)
+++ /dev/null
-/*
- * testoffscreen.c
- */
-
-#include <math.h>
-#include <string.h>
-#include <gtk/gtk.h>
-#include "gtkoffscreenbox.h"
-
-
-static void
-combo_changed_cb (GtkWidget *combo,
- gpointer data)
-{
- GtkWidget *label = GTK_WIDGET (data);
- gint active;
-
- active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
-
- gtk_label_set_ellipsize (GTK_LABEL (label), (PangoEllipsizeMode)active);
-}
-
-static gboolean
-layout_draw_handler (GtkWidget *widget,
- cairo_t *cr)
-{
- GtkLayout *layout = GTK_LAYOUT (widget);
- GdkWindow *bin_window = gtk_layout_get_bin_window (layout);
- GdkRectangle clip;
-
- gint i, j, x, y;
- gint imin, imax, jmin, jmax;
-
- if (!gtk_cairo_should_draw_window (cr, bin_window))
- return FALSE;
-
- gdk_window_get_position (bin_window, &x, &y);
- cairo_translate (cr, x, y);
-
- gdk_cairo_get_clip_rectangle (cr, &clip);
-
- imin = (clip.x) / 10;
- imax = (clip.x + clip.width + 9) / 10;
-
- jmin = (clip.y) / 10;
- jmax = (clip.y + clip.height + 9) / 10;
-
- for (i = imin; i < imax; i++)
- for (j = jmin; j < jmax; j++)
- if ((i + j) % 2)
- cairo_rectangle (cr,
- 10 * i, 10 * j,
- 1 + i % 10, 1 + j % 10);
-
- cairo_fill (cr);
-
- return FALSE;
-}
-
-static gboolean
-scroll_layout (gpointer data)
-{
- GtkWidget *layout = data;
- GtkAdjustment *adj;
-
- adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (layout));
- gtk_adjustment_set_value (adj, gtk_adjustment_get_value (adj) + 5.0);
- return G_SOURCE_CONTINUE;
-}
-
-static guint layout_timeout;
-
-static void
-create_layout (GtkWidget *vbox)
-{
- GtkAdjustment *hadjustment, *vadjustment;
- GtkLayout *layout;
- GtkWidget *layout_widget;
- GtkWidget *scrolledwindow;
- GtkWidget *button;
- gchar buf[16];
- gint i, j;
-
- scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow),
- GTK_SHADOW_IN);
- gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW (scrolledwindow),
- GTK_CORNER_TOP_RIGHT);
-
- gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE);
-
- layout_widget = gtk_layout_new (NULL, NULL);
- layout = GTK_LAYOUT (layout_widget);
- gtk_container_add (GTK_CONTAINER (scrolledwindow), layout_widget);
-
- /* We set step sizes here since GtkLayout does not set
- * them itself.
- */
- hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (layout));
- vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (layout));
- gtk_adjustment_set_step_increment (hadjustment, 10.0);
- gtk_adjustment_set_step_increment (vadjustment, 10.0);
- gtk_scrollable_set_hadjustment (GTK_SCROLLABLE (layout), hadjustment);
- gtk_scrollable_set_vadjustment (GTK_SCROLLABLE (layout), vadjustment);
-
- gtk_widget_set_events (layout_widget, GDK_EXPOSURE_MASK);
- g_signal_connect (layout, "draw",
- G_CALLBACK (layout_draw_handler),
- NULL);
-
- gtk_layout_set_size (layout, 1600, 128000);
-
- for (i = 0 ; i < 16 ; i++)
- for (j = 0 ; j < 16 ; j++)
- {
- g_snprintf (buf, sizeof (buf), "Button %d, %d", i, j);
-
- if ((i + j) % 2)
- button = gtk_button_new_with_label (buf);
- else
- button = gtk_label_new (buf);
-
- gtk_layout_put (layout, button, j * 100, i * 100);
- }
-
- for (i = 16; i < 1280; i++)
- {
- g_snprintf (buf, sizeof (buf), "Button %d, %d", i, 0);
-
- if (i % 2)
- button = gtk_button_new_with_label (buf);
- else
- button = gtk_label_new (buf);
-
- gtk_layout_put (layout, button, 0, i * 100);
- }
-
- layout_timeout = g_timeout_add (1000, scroll_layout, layout);
-}
-
-static void
-create_treeview (GtkWidget *vbox)
-{
- GtkWidget *scrolledwindow;
- GtkListStore *store;
- GtkWidget *tree_view;
- GtkIconTheme *icon_theme;
- GList *icon_names;
- GList *list;
-
- scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow),
- GTK_SHADOW_IN);
-
- gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE);
-
- store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
- tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
- g_object_unref (store);
-
- gtk_container_add (GTK_CONTAINER (scrolledwindow), tree_view);
-
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), -1,
- "Icon",
- gtk_cell_renderer_pixbuf_new (),
- "icon-name", 0,
- NULL);
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), -1,
- "Label",
- gtk_cell_renderer_text_new (),
- "text", 1,
- NULL);
-
- icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (vbox));
- icon_names = gtk_icon_theme_list_icons (icon_theme, NULL);
- icon_names = g_list_sort (icon_names, (GCompareFunc) strcmp);
-
- for (list = icon_names; list; list = g_list_next (list))
- {
- const gchar *name = list->data;
-
- gtk_list_store_insert_with_values (store, NULL, -1,
- 0, name,
- 1, name,
- -1);
- }
-
- g_list_free_full (icon_names, g_free);
-}
-
-static GtkWidget *
-create_widgets (void)
-{
- GtkWidget *main_hbox, *main_vbox;
- GtkWidget *vbox, *hbox, *label, *combo, *entry, *button, *cb;
- GtkWidget *sw, *text_view;
-
- main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-
- main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start (GTK_BOX (main_vbox), main_hbox, TRUE, TRUE);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start (GTK_BOX (main_hbox), vbox, TRUE, TRUE);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE);
-
- label = gtk_label_new ("This label may be ellipsized\nto make it fit.");
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE);
-
- combo = gtk_combo_box_text_new ();
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "NONE");
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "START");
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "MIDDLE");
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "END");
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
- gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE);
-
- g_signal_connect (combo, "changed",
- G_CALLBACK (combo_changed_cb),
- label);
-
- entry = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY (entry), "an entry - lots of text.... lots of text.... lots of text.... lots of text.... ");
- gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE);
-
- label = gtk_label_new ("Label after entry.");
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE);
-
- button = gtk_button_new_with_label ("Button");
- gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE);
-
- button = gtk_check_button_new_with_mnemonic ("_Check button");
- gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE);
-
- cb = gtk_combo_box_text_new ();
- entry = gtk_entry_new ();
- gtk_widget_show (entry);
- gtk_container_add (GTK_CONTAINER (cb), entry);
-
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb), "item0");
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb), "item1");
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb), "item1");
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb), "item2");
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb), "item2");
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb), "item2");
- gtk_entry_set_text (GTK_ENTRY (entry), "hello world ♥ foo");
- gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
- gtk_box_pack_start (GTK_BOX (vbox), cb, TRUE, TRUE);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- text_view = gtk_text_view_new ();
- gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE);
- gtk_container_add (GTK_CONTAINER (sw), text_view);
-
- create_layout (vbox);
-
- create_treeview (main_hbox);
-
- return main_vbox;
-}
-
-
-static void
-scale_changed (GtkRange *range,
- GtkOffscreenBox *offscreen_box)
-{
- gtk_offscreen_box_set_angle (offscreen_box, gtk_range_get_value (range));
-}
-
-static GtkWidget *scale = NULL;
-
-static void
-remove_clicked (GtkButton *button,
- GtkWidget *widget)
-{
- gtk_widget_destroy (widget);
- g_source_remove (layout_timeout);
-
- gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
- gtk_widget_set_sensitive (scale, FALSE);
-}
-
-int
-main (int argc,
- char *argv[])
-{
- GtkWidget *window, *widget, *vbox, *button;
- GtkWidget *offscreen = NULL;
- gboolean use_offscreen;
-
- gtk_init (&argc, &argv);
-
- use_offscreen = argc == 1;
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size (GTK_WINDOW (window), 300,300);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_main_quit),
- NULL);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add (GTK_CONTAINER (window), vbox);
-
- scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
- 0, G_PI * 2, 0.01);
- gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE);
-
- button = gtk_button_new_with_label ("Remove child 2");
- gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE);
-
- if (use_offscreen)
- {
- offscreen = gtk_offscreen_box_new ();
-
- g_signal_connect (scale, "value_changed",
- G_CALLBACK (scale_changed),
- offscreen);
- }
- else
- {
- offscreen = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
- }
-
- gtk_box_pack_start (GTK_BOX (vbox), offscreen, TRUE, TRUE);
-
- widget = create_widgets ();
- if (use_offscreen)
- gtk_offscreen_box_add1 (GTK_OFFSCREEN_BOX (offscreen),
- widget);
- else
- gtk_paned_add1 (GTK_PANED (offscreen), widget);
-
- widget = create_widgets ();
- if (1)
- {
- GtkWidget *widget2, *box2, *offscreen2;
-
- offscreen2 = gtk_offscreen_box_new ();
- gtk_box_pack_start (GTK_BOX (widget), offscreen2, FALSE, FALSE);
-
- g_signal_connect (scale, "value_changed",
- G_CALLBACK (scale_changed),
- offscreen2);
-
- box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_offscreen_box_add2 (GTK_OFFSCREEN_BOX (offscreen2), box2);
-
- widget2 = gtk_button_new_with_label ("Offscreen in offscreen");
- gtk_box_pack_start (GTK_BOX (box2), widget2, FALSE, FALSE);
-
- widget2 = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY (widget2), "Offscreen in offscreen");
- gtk_box_pack_start (GTK_BOX (box2), widget2, FALSE, FALSE);
- }
-
- if (use_offscreen)
- gtk_offscreen_box_add2 (GTK_OFFSCREEN_BOX (offscreen), widget);
- else
- gtk_paned_add2 (GTK_PANED (offscreen), widget);
-
- gtk_widget_show_all (window);
-
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (remove_clicked),
- widget);
-
- gtk_main ();
-
- return 0;
-}
+++ /dev/null
-#include <gtk/gtk.h>
-
-static gboolean
-da_draw (GtkWidget *widget,
- cairo_t *cr,
- gpointer user_data)
-{
- GtkOffscreenWindow *offscreen = (GtkOffscreenWindow *)user_data;
-
- cairo_set_source_surface (cr,
- gtk_offscreen_window_get_surface (offscreen),
- 50, 50);
- cairo_paint (cr);
-
- return FALSE;
-}
-
-static gboolean
-offscreen_damage (GtkWidget *widget,
- GdkEventExpose *event,
- GtkWidget *da)
-{
- gtk_widget_queue_draw (da);
-
- return TRUE;
-}
-
-static gboolean
-da_button_press (GtkWidget *area, GdkEventButton *event, GtkWidget *button)
-{
- gtk_widget_set_size_request (button, 150, 60);
- return TRUE;
-}
-
-int
-main (int argc, char **argv)
-{
- GtkWidget *window;
- GtkWidget *button;
- GtkWidget *offscreen;
- GtkWidget *da;
-
- gtk_init (&argc, &argv);
-
- offscreen = gtk_offscreen_window_new ();
-
- button = gtk_button_new_with_label ("Test");
- gtk_widget_set_size_request (button, 50, 50);
- gtk_container_add (GTK_CONTAINER (offscreen), button);
- gtk_widget_show (button);
-
- gtk_widget_show (offscreen);
-
- /* Queue exposures and ensure they are handled so
- * that the result is uptodate for the first
- * expose of the window. If you want to get further
- * changes, also track damage on the offscreen
- * as done above.
- */
- gtk_widget_queue_draw (offscreen);
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "delete-event",
- G_CALLBACK (gtk_main_quit), window);
- da = gtk_drawing_area_new ();
- gtk_container_add (GTK_CONTAINER (window), da);
-
- g_signal_connect (da,
- "draw",
- G_CALLBACK (da_draw),
- offscreen);
-
- g_signal_connect (offscreen,
- "damage-event",
- G_CALLBACK (offscreen_damage),
- da);
-
- gtk_widget_add_events (da, GDK_BUTTON_PRESS_MASK);
- g_signal_connect (da, "button_press_event", G_CALLBACK (da_button_press),
- button);
-
- gtk_widget_show_all (window);
-
- gtk_main();
-
- return 0;
-}
if (type == GTK_TYPE_COLOR_BUTTON && pspec->owner_type == GTK_TYPE_BUTTON)
continue;
- /* GdkOffscreenWindow is missing many implementations */
- if (type == GTK_TYPE_OFFSCREEN_WINDOW)
- continue;
-
/* Too many special cases involving -set properties */
if (g_str_equal (g_type_name (pspec->owner_type), "GtkCellRendererText") ||
g_str_equal (g_type_name (pspec->owner_type), "GtkTextTag"))
gtk_list_store_insert_with_values (store, &iter, 3, 0, "Row content", -1);
gtk_list_store_insert_with_values (store, &iter, 4, 0, "Row content", -1);
- window = gtk_offscreen_window_new ();
+ window = gtk_invisible_new ();
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (tree_view),
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
- <object class="GtkOffscreenWindow" id="window1">
+ <object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="type">popup</property>
<signal name="realize" handler="reftest:set_default_direction_ltr"/>
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
- <object class="GtkOffscreenWindow" id="window1">
+ <object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="type">popup</property>
<signal name="realize" handler="reftest:set_default_direction_ltr"/>